Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 476
fabiomaia Avatar asked May 09 '18 15:05

fabiomaia


People also ask

What is the restart policy in Docker compose?

Restart Policy in Docker Compose Like the restart Docker command, Docker Compose includes the restart property to restart containers automatically. Besides, we can define restart policies in Docker Compose by providing the restart property to the service in the docker-compose. yml file.

What is the Docker command to add or update a published port?

Use the --publish-add or --publish-rm flags to add or remove a published port for a service.

What happens by default when a docker service image is updated?

By default, when an update to an individual task returns a state of RUNNING , the scheduler schedules another task to update until all tasks are updated. If, at any time during an update a task returns FAILED , the scheduler pauses the update.


1 Answers

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

like image 113
yamenk Avatar answered Nov 15 '22 03:11

yamenk