Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker swarm services stuck in preparing

Tags:

I have a swarm stack deployed and I removed couple services from the stack and tried to deploy them again. these services are showing with desired state remove and current state preparing .. also their name got changed from the custom service name to a random docker name. swarm also trying to start these services which are also stuck in preparing. I ran docker system prune on all nodes and them removed the stack. all the services in the stack are not existent anymore except for the random ones. now I cant delete them and they still in preparing state. the services are not running anywhere in the swarm but I want to know if there is a way to remove them.

like image 378
tkyass Avatar asked Sep 18 '18 23:09

tkyass


People also ask

How do I stop docker from running in swarm mode?

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.

Is Docker swarm mode deprecated?

Docker Swarm is not being deprecated, and is still a viable method for Docker multi-host orchestration, but Docker Swarm Mode (which uses the Swarmkit libraries under the hood) is the recommended way to begin a new Docker project where orchestration over multiple hosts is required.

When a task stops it is not executed again and a new task may take its place?

When a task stops, it isn't executed again, but a new task may take its place. Tasks advance through a number of states until they complete or fail. Tasks are initialized in the NEW state. The task progresses forward through a number of states, and its state doesn't go backward.


1 Answers

I had the same problem. Later I found that the current state, 'Preparing' indicates that docker is trying to pull images from docker hub. But there is no clear indicator in docker service logs <serviceName> available in the docker-compose-version above '3.1'.

But it sometimes imposes the latency due to n\w bandwidth or other docker internal reasons.

Hope it helps! I will update the answer if I find more relevant information.

P.S. I identified that docker stack deploy -c <your-compose-file> <appGroupName> is not stuck when switching the command to docker-compose up. For me, it took 20+ minutes to download my image for some reasons.

So, it proves that there is no open issues with docker stack deploy,

Adding reference from Christian to club and complete this answer.

Use docker-machine ssh to connect to a particular machine:

docker-machine ssh <nameOfNode/Machine>

Your prompt will change. You are now inside another machine. Inside this other machine do this:

tail -f /var/log/docker.log

You'll see the "daemon" log for that machine. There you'll see if that particular daemon is doing the "pull" or what's is doing as part of the service preparation. In my case, I found something like this:

time="2016-09-05T19:04:07.881790998Z" level=debug msg="pull progress map[progress:[===========================================>       ] 112.4 MB/130.2 MB status:Downloading

Which made me realise that it was just downloading some images from my docker account.

like image 59
Ashokan Sivapragasam Avatar answered Sep 28 '22 18:09

Ashokan Sivapragasam