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:~#
Copy Code
Copy Code
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
Copy Code
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'
Copy Codesudo rm -rf
Copy Code - If the above fails, simply delete the default docker image directory. Make a backup before running this command.
sudo rm -rf /var/lib/docker
Copy Code - Then, delete the docker runtime files. Before running this command, we should make a backup.
sudo rm -rf /var/run/docker
Copy Code - 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
Copy Code - Then reinstall Docker.
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
Copy Codesudo yum install docker-ce docker-ce-cli containerd.io
Copy Code - Then start docker.
sudo systemctl start docker
Copy Code - Finally, check the docker installation.
sudo docker run hello-world
Copy Code
Solution-2
If solution one does not work, we can try the following:
- Firstly, to remove the
argument that is used by default when starting the daemon, create a new file-H
Copy Code
with the following contents./etc/systemd/system/docker.service.d/docker.conf
Copy Code[Service] ExecStart= ExecStart=/usr/bin/dockerd
Copy Code - Then, in
, create a new file “daemon.json” with the following contents: { “debug”: true, “hosts”: [“tcp://127.0.0.1:2375”] }/etc/docker/
Copy Code - Finally, Systemctl should be reloaded.
sudo systemctl daemon-reload
Copy Codesudo systemctl stop docker.service
Copy Codesudo systemctl start docker.service
Copy Code
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%
Copy Code - The
command will not return anything if a container does not respond.inspect
Copy Code - Once we’ve identified the %CONTAINER ID% not responding, look for the PID that corresponds to it:
ps -aux | grep %CONTAINER ID%
Copy Code - Finally, use
to terminate this service.kill -9 %PID%
Copy Code
[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