Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'docker ps' hangs forever after server restart

Tags:

docker

After server restart docker looks alive but all commands like docker ps hang forever until I press Ctrl+C. What can be wrong?

Docker version 1.12.6, build 7392c3b/1.12.6 Linux ip-10-0-1-124 4.4.10-22.54.amzn1.x86_64

like image 693
snowindy Avatar asked Mar 20 '17 10:03

snowindy


People also ask

Why does docker stop take so long?

If even one of your containers does not respond to SIGTERM signals, Docker will wait for 10 seconds at least. If your containers depend on each other, docker-compose can't shut them down all at once. It will ask them to stop in the right order, waiting for each one. This waiting time can add up.

How do I force quit docker?

docker rm -f The final option for stopping a running container is to use the --force or -f flag in conjunction with the docker rm command. Typically, docker rm is used to remove an already stopped container, but the use of the -f flag will cause it to first issue a SIGKILL.

Does docker restart after reboot?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.

Why do I lose data if docker restarts?

Yes, once your container ceases to exist or you restart it, the data will be lost. But that can be easily fixed if you use persistent volumes to store your data. My preferred solution is to use a container orchestrator like Swarm, Kubernetes, etc. I'll expand on volumes in Kubernetes a little bit.


1 Answers

It turned out instance had uptime for over a year, many application releases were installed, /var/lib/docker/devicemapper folder contained hundreds of items that apparently refer to older abandoned containers.

I saw the process of eternal reading all this data while dockerd -D command that runs docker interactively for debugging.

I removed /var/lib/docker and /var/run/docker and re-installed docker and containers on my box, the problem was resolved.

Feels like I need a script that would periodically remove obsolete items from docker internals.

like image 87
snowindy Avatar answered Sep 25 '22 08:09

snowindy