Docker system prune hangs when the docker daemon process is stuck for some reason.
Bobcares responds to all inquiries, big or small, as part of our Docker hosting support.
Let’s take a closer look at how our Support team helped one of our customers resolve a Docker system prune hangs issue.
Docker system Prune Hangs
When we use docker from command line , sometimes, the docker command hang indefinitely without any response. It happens when we use any of the docker commands docker info, docker help, docker version, docker ps, and docker images.
root@bobcares:~# docker ps
^C
root@bobcares:~#
CTRL+C is the only way to exit the command. This is because we are actually connecting the docker daemon service from the docker client command when we use docker info/docker version/docker ps/docker images. The Docker daemon is merely a service that provides a restful web service via socket.
Docker daemon
The Docker daemon (dockerd) manages Docker objects such as images, containers, networks, and volumes by listening for Docker API requests. To manage Docker services, a daemon can communicate with other daemons.
Docker client
Many Docker users interact with Docker primarily through the Docker client (docker). When we use commands like docker run, the client sends them to dockerd, which executes them. The Docker API is used by the docker command. The Docker client has the ability to communicate with multiple daemons.
Solve Docker hang when using docker ps commands
There are several options to solve this problem:
Solution-1
The most important aspect of this solution is to delete all docker images and logs from the system. Remove any docker images that are no longer needed.
docker system prune -a
If the above command does not work or hangs, try the steps below:-
- Firstly, get the root directory of docker images.
docker info |grep 'Docker Root Dir'
sudo rm -rf
- If the above fails, simply delete the default docker image directory. Make a backup before running this command.
sudo rm -rf /var/lib/docker
- Then, delete the docker runtime files. Before running this command, we should make a backup.
sudo rm -rf /var/run/docker
- Now we can try docker info. If it still isn’t working, we can try uninstalling and reinstalling the docker.
sudo yum remove docker docker-common docker-selinux docker-engine
- Then reinstall Docker.
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
- Then start docker.
sudo systemctl start docker
- Finally, check the docker installation.
sudo docker run hello-world
Solution-2
If solution one does not work, we can try the following:
- Firstly, to remove the
-H
argument that is used by default when starting the daemon, create a new file/etc/systemd/system/docker.service.d/docker.conf
with the following contents.[Service] ExecStart= ExecStart=/usr/bin/dockerd
- Then, in
/etc/docker/
, create a new file “daemon.json” with the following contents: { “debug”: true, “hosts”: [“tcp://127.0.0.1:2375”] } - Finally, Systemctl should be reloaded.
sudo systemctl daemon-reload
sudo systemctl stop docker.service
sudo systemctl start docker.service
Solution-3
If the docker version is too old (less then 13), reboot the system .
Solve Docker prune stuck in “a prune operation is already running”
When a container fails to respond to Docker, this problem appears. Here’s how we got it fixed.
- Firstly, locate the containers that are not responding.
sudo docker inspect %CONTAINER ID%
- The
inspect
command will not return anything if a container does not respond. - Once we’ve identified the %CONTAINER ID% not responding, look for the PID that corresponds to it:
ps -aux | grep %CONTAINER ID%
- Finally, use
kill -9 %PID%
to terminate this service.
[Looking for a solution to another query? We are just a click away.]
Conclusion
To sum up, our Support team demonstrates how to fix a Docker system prune hangs problem.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
0 Comments