Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to stop, start single task in docker swarm mode?

Is there a way to stop, start the single task in docker swarm mode, And how to do this?

like image 505
sope Avatar asked Aug 15 '16 05:08

sope


People also ask

How do I stop a process from running in docker?

To stop a container you use the docker stop command and pass the name of the container and the number of seconds before a container is killed. The default number of seconds the command will wait before the killing is 10 seconds.

How do I stop a single docker container?

To stop one or more running Docker containers, you can use the docker stop command. The syntax is simple: $ docker stop [OPTIONS] CONTAINER [CONTAINER...] You can specify one or more containers to stop.

How do I stop a docker from swarm stacking?

Swarm mode orchestration has the objective to make the current state match your target definition. So "stop all the containers" brings your current state out of the target state goal and swarm will try to correct that. You could do this by changing your target, but that needs to be done per service.


2 Answers

Scale down to 0

e.g.

> docker service scale tpg6hs1c4atg=0
tpg6hs1c4atg scaled to 0
overall progress: 0 out of 0 tasks
verify: Service converged
like image 142
Naor Bar Avatar answered Oct 26 '22 11:10

Naor Bar


At the moment the only way to run containers in swarm mode is to create a service: docker service create --name my-service my/image. Also, if you want to "stop" a service, you have to remove it: docker service rm my-service.

In future you'll be able to start services using DAB files, which are quite similar to docker-compose.yml files, but for docker swarm mode.

like image 29
ronkot Avatar answered Oct 26 '22 10:10

ronkot