Docker Swarm:restart-policy不允许使用其他属性restart-policy

时间:2018-05-09 15:33:43

标签: docker docker-swarm

鉴于以下内容(为了论证而简化)docker-compose.yml文件:

version: '3'

services:
  postgres:
    image: fleetit-postgres
    deploy:
      restart-policy:
        condition: on-failure
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: "root"
      POSTGRES_PASSWORD: "demo1234"
      POSTGRES_DB: "fleetit"

我试图使用命令

部署堆栈
docker stack deploy -c docker-compose.yml stackdemo

但它只是把错误抛给了我

restart-policy Additional property restart-policy is not allowed

我做错了什么?

这是我正在运行的Docker版本:

$ docker version
Client:
 Version:   18.04.0-ce
 API version:   1.37
 Go version:    go1.10.1
 Git commit:    3d479c0af6
 Built: Tue Apr 17 22:46:17 2018
 OS/Arch:   linux/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.04.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.10.1
  Git commit:   3d479c0af6
  Built:    Tue Apr 17 22:46:48 2018
  OS/Arch:  linux/amd64
  Experimental: false

1 个答案:

答案 0 :(得分:3)

你有一个错字。它应该是restart_policy,带有下划线而不是restart-policy