I am new in docker swarm mode. As you know it possible to start/stop docker container but i see no possibility to do this in swarm.
For example, I've deployed swarm and created new tasks with replica(2/2):
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
2o3a6z30q9df contactactivity replicated 2/2 myimage/live-springboot-myservice:19ff0be1f0087asd1dasdb52c345151e9985b4a5a2 *:111->1111/tcp
Is it possible to stop one of the swarm containers without removing it and bring it back in future?
P.S. I am just want to clarify that remove or recreate - is not the option in my case.
To make Q clear: If you stop container and then start - this container wont be a part of swarm. I cannot believe that in swarm mode there is no way to do simple restart or start/stop.
Run the docker swarm leave command on a node to remove it from the swarm. For example to leave the swarm on a worker node: $ docker swarm leave Node left the swarm. When a node leaves the swarm, the Docker Engine stops running in swarm mode.
The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...] You can specify one or more containers to stop. The only option for docker stop is -t (–time) which allows you to specify a wait time before stopping a container.
Updating the existing service, swarm will recreate all containers. For example, you can simply update a property of the service to archive restarting.
List the containers running for the service & stop them
for example
docker ps | grep service-name
and then stop the container by using docker stop <ID>
from above command.
OR
If you want to stop all containers then just scale down the service to 0
like below
docker service scale servicename=0
bring them back using
docker service scale servicename=N
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