Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to force deletion of docker containers

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to forcibly delete docker containers, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

How do I force the deletion of a docker container? Sometimes we may encounter the problem that the container service cannot be stopped or deleted in docker. The directory of docker cannot be deleted by executing the delete command.

Here, replace caf8ef20f3c1 with the container ID where you want stop.

Ll / var/lib/docker/containers | grep caf8ef20f3c1cd / var/lib/docker/containersrm-rf caf8ef20f3c1c78f03a5844ee23abc1d7e44246f242292040f1ef288899d0cb8

At this time, we will receive such an error report.

Rm: cannot delete "/ var/lib/docker/containers/caf8ef20f3c1c78f03a5844ee23abc1d7e44246f242292040f1ef288899d0cb8/secrets": device or resource busy cannot delete "/ var/lib/docker/containers/caf8ef20f3c1c78f03a5844ee23abc1d7e44246f242292040f1ef288899d0cb8/shm": device or resource is busy

From the error report, we can see that the shared mount of "secrets" and "shm" cannot be deleted. First, find the location of the mount, then cancel the mount, and then delete it:

Cat / proc/mounts | grep "docker" | grep "caf8ef20f3c1"

Unmount, this is the mount directory above

Umount / data/sys/var/docker/containers/caf8ef20f3c1c78f03a5844ee23abc1d7e44246f242292040f1ef288899d0cb8/secretsumount / data/sys/var/docker/containers/caf8ef20f3c1c78f03a5844ee23abc1d7e44246f242292040f1ef288899d0cb8/shm

If you check it again, it is no longer displayed.

Cat / proc/mounts | grep "docker" | grep "caf8ef20f3c1"

Now delete the directory of docker:

Cd / var/lib/docker/containersrm-rf caf8ef20f3c1c78f03a5844ee23abc1d7e44246f242292040f1ef288899d0cb8

Now let's use rm or kill to delete the container service:

Docker rm-f caf8ef20f3c1c or docker kill-- signal=SIGINT caf8ef20f3c1

If the hang gets stuck after the above command is run, restart the docker service:

Sudo service docker restart

So much for sharing about how to forcibly delete docker containers. I hope the above content can be helpful to you and you can learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report