Docker - Cannot remove dead container

后端 未结 20 1508
清歌不尽
清歌不尽 2020-12-22 16:28

I am unable to remove the dead container, it appears again after i restart the Docker service.

docker ps -a
CONTAINER ID         STATUS          
11667ef1623         


        
相关标签:
20条回答
  • 2020-12-22 17:06

    I have tried the suggestions above but didn't work.

    Then

    1. I try : docker system prune -a, it didn't work the first time
    2. I reboot the system
    3. I try again docker system prune -a. This time it works. It will send a warning message and in the end ask "Are you sure you want to continue? y/n? . Ans:y . It will time a time and in the end the dead containers are gone.
    4. Verify with docker ps -a

    IMPORTANT - this is the nuclear option as it destroys all containers + images

    0 讨论(0)
  • 2020-12-22 17:08

    Removing container by force worked for me.

    docker rm -f <id_of_the_dead_container>

    Notes:

    Be aware that this command might throw this error Error response from daemon: Driver devicemapper failed to remove root filesystem <id_of_the_dead_container>: Device is Busy

    The mount of your's dead container device mapper should be removed despite this message. That is, you will no longer access this path:

    /var/lib/docker/devicemapper/mnt/<id_of_the_dead_container>

    0 讨论(0)
  • 2020-12-22 17:10

    Try running the following commands. It always works for me.

    # docker volume rm $(docker volume ls -qf dangling=true)
    # docker rm $(docker ps -q -f 'status=exited')
    

    After execution of the above commands, restart docker by,

    # service docker restart
    
    0 讨论(0)
  • 2020-12-22 17:10
    grep 656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3 /proc/*/mountinfo
    

    then find the pid of 656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3and and kill it

    0 讨论(0)
  • 2020-12-22 17:12
    1. For Deleting all dead container docker rm -f $(docker ps --all -q -f status=dead)

    2. For deleting all exited container docker rm -f $(docker ps --all -q -f status=exited)

    As I have -f is necessary

    0 讨论(0)
  • 2020-12-22 17:13

    Most likely, an error occurred when the daemon attempted to cleanup the container, and he is now stuck in this "zombie" state.

    I'm afraid your only option here is to manually clean it up:

    $ sudo rm -rf /var/lib/docker/<storage_driver>/11667ef16239.../
    

    Where <storage_driver> is the name of your driver (aufs, overlay, btrfs, or devicemapper).

    0 讨论(0)
提交回复
热议问题