Home > Article > Operation and Maintenance > Docker cannot be shut down? You may need these methods to solve the problem
As a world-renowned virtualization technology, Docker has become one of the standard features of modern application workflows. However, despite the convenience that Docker brings, some users may encounter some difficult problems. One of them is the problem that Docker cannot be shut down. In this article, we will explore some of the difficulties you may encounter and provide solutions to fix Docker not shutting down.
Possible causes
First, let’s take a look at some possible reasons why Docker cannot be shut down:
We will provide a solution for each possible cause.
Workaround
If Docker fails to shut down, the first possible cause is the container in use or mount point. To resolve this issue, you can try to see which containers are being used by doing the following:
$ docker ps
If you see containers in use, try stopping and deleting them:
$ docker stop [CONTAINER ID]
$ docker rm [CONTAINER ID]
If there are other containers in use, perform the same operation until all containers are stopped and deleted.
Similarly, if you can determine that you are using a mount point, use the umount command to try to unmount:
$ umount [PATH]
If the umount command does not work Function, use the fuser command to find the processes that are using the mount point:
$ fuser -m [PATH]
Then, use the kill command to end these processes:
$ kill -9 [PID]
Now you should be able to stop Docker and shut it down.
If Docker cannot be shut down, another possible reason is that the Docker daemon has crashed or has been left behind. To resolve this issue, you can try the following:
$ sudo service docker status
If you see The Docker daemon is running, please try to stop it:
$ sudo service docker stop
$ sudo killall docker
Alternatively, use the following command to find the running Docker daemon:
$ ps aux | grep docker
After running the above command, you You will see the PID of the running Docker daemon. Use the kill command and specify the PID to end it.
$ sudo rm -rf /var/lib/docker
Now, restart the Docker daemon:
$ sudo service docker start
Your Docker should be able to shut down normally.
If Docker fails to shut down, the last possible reason is resource exhaustion. This includes disk space, memory, and processor resources.
In order to solve this problem, you can try to release resources. Use the following command to view disk space usage:
$ df -h
If you are low on disk space, delete unnecessary files and containers. Use the following command to view memory usage:
$ free -m
If memory resources are exhausted, try to free the memory. The memory disk cache can be cleared using the following command:
$ sudo sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
If processor resources are exhausted, try stopping other runs process. Find running processes using the following command:
$ top
Use the kill command or other tools to end unwanted processes.
Summary
Although Docker is a great virtualization technology, sometimes problems can occur, such as being unable to shut down. In this article, we explore the possible causes and provide solutions to fix Docker not shutting down.
Whether a container or mount point is active, the Docker daemon has crashed or been left behind, or resources are exhausted, we've provided some ways to resolve the issue. If you encounter similar issues, please try these methods so that you can shut down and restart your Docker smoothly.
The above is the detailed content of Docker cannot be shut down? You may need these methods to solve the problem. For more information, please follow other related articles on the PHP Chinese website!