Search code examples
dockerdocker-swarm

Docker Swarm: restart-policy Additional property restart-policy is not allowed


Given the following (simplified for the sake of argument) docker-compose.yml file:

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"

I was trying to deploy a stack with the command

docker stack deploy -c docker-compose.yml stackdemo

But it just throws me the error

restart-policy Additional property restart-policy is not allowed

What am I doing wrong?

This is the version of Docker I am running:

$ 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

Solution

  • You have a typo. Its should be restart_policy with an underscore instead of restart-policy.