I am currently using Docker Swarm Mode in pipeline and i use massively docker stack deploy -c compose-file.yml name-of-the-stack
as a command to update the stack with the latest docker image. It perfectly works unless i do not remove a service from the yaml file. In this case the stack deploy
command should remove the no more exisisting service on top of update the image of the other, but the behaviour is that it leaves the container running and this is not the expected behavior.
As consequence of this i changed it with a docker stack rm name-of-the-service
and then docker stack deploy -c compose-file.yml name-of-stack
. But this has another awful side effect that randomly affects the containers : the commands docker stack rm name-of-the-stack
often makes the reliability of the nginx container proxypass totally unreliable (seems related to this issue https://github.com/docker/docker/issues/24244) .
As a matter of fact, the nginx container (that is in another stack but in the same overlay network) , that is in charge to handle all requests between containers and make proxypass between them using the routing mesh feature of the Docker Swarm Mode, after the re-creation of the stack deployed, fails to proxy requests, like if it try to forward traffic to no more exisisting containers, and this make the integration and behavioral tests fail.
Is there a way to deploy consistently without using docker stack rm (that seems pretty buggy so far) but applying the latest state of the yml compose file?
You need to include the --prune
option in your docker stack deploy
command:
$ docker stack deploy --help
Usage: docker stack deploy [OPTIONS] STACK
Deploy a new stack or update an existing stack
Aliases:
deploy, up
Options:
--bundle-file string Path to a Distributed Application Bundle file
-c, --compose-file string Path to a Compose file
--help Print usage
--prune Prune services that are no longer referenced
--with-registry-auth Send registry authentication details to Swarm agents
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With