March 1, 2023, 5:58pm
I’d like to have a service deployed in Swarm run some commands then stop.
My compose file will start a service, run some commands, then run the commands again. As in an endless loop.
I added the following restart policy:
restart: on-failure. When I deployed, I got the following message:
Ignoring unsupported options: restart. However, the service ran the commands once.
My compose file is (showing relevant parts):
# A bunch of commands are being executed in this section
constraints: [node.labels.server == 1]
What’s the best way to implement my desired scenario? Is the ignore message a false positive?
docker-compose v1.29.2, build unknown
docker version 23.0.0, build e92dd87
Ubuntu 22.04.2 LTS
March 1, 2023, 9:51pm
If you use Swarm, you don’t need Docker compose so the version is irrelevant. Still thank you for sharing the versions without us asking for it.
I don’t know why it was restarted only once, but as the
I also searched for the error message:
Ignoring unsupported options: restart
and the first result was this:
which refers to this part of the documentation:
That shows Compose file v3 reference where there were
deploy.restart_policy options as well. Using the new compose file specification and Compose v2 you could use the same for Docker Compose and Swarm
The “condition” can also be “none”, so it will never be restarted.
March 1, 2023, 10:25pm
Ah, I was setting incorrectly. Thanks!