Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove docker container even if root filesystem does not exists?

Tags:

docker

I have one container that is dead, but I can't remove it, as you can see below.

How can I remove it? Or how can I clean my system manually to remove it?

:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
78b0dcaffa89        ubuntu:latest       "bash -c 'while tr..."   30 hours ago        Dead                                    leo.1.bkbjt6w08vgeo39rt1nmi7ock

:~$ docker rm --force 78b0dcaffa89
Error response from daemon: driver "aufs" failed to remove root filesystem for 78b0dcaffa89ac1e532748d44c9b2f57b940def0e34f1f0d26bf7ea1a10c222b: no such file or directory
like image 515
Azize Avatar asked Jul 04 '17 12:07

Azize


People also ask

How to fix “error – unable to remove filesystem” in Docker?

In this post, we will explore How To Fix – “Error: Unable to Remove FileSystem” in Docker. There are various formats of the error based on the scenarios. CAdvisor is one of the most common reason of this error. Utilities like CAdvisor mount the Docker system dirs in the container. You should run teh CAdvisor container as shown below –

Is it possible to delete Docker containers?

If you want to remove all containers, stop the running ones first and then remove them: But you won’t always have a simple life with containers. And this is why I am going to show various scenarios in which you can delete docker containers. How to confirm that Docker has been installed successfully?

What happens when you exit a docker container?

If you exit the container this way, your container stops as well. As you can see on the output above, the docker ps command shows no running containers. This docker tutorial discusses methods to stop a single docker container, multiple docker containers or all running docker containers at once.

How to remove all unused volumes in Docker?

Removing all unused volumes # To remove all unused volumes, run the docker image prune command: docker volume prune WARNING! This will remove all local volumes not used by at least one container. Are you sure you want to continue? [y/N] Use the -f or --force option to bypass the prompt. Removing Docker Networks # Removing one or more networks #


Video Answer


3 Answers

Its possible Docker needs to be restarted.

I just ran into the same error message when trying to remove a container, and restarting Docker helped.

I'm running Version 17.12.0-ce-mac49 (21995)

To restart Docker, go to "Preferences" and click on the little bomb in the upper right hand corner.

In my situation I have Docker running off of a expansion drive on my MacBook. After coming out of sleep mode, the expansion drive was automatically ejected (undesirable). But after mounting the drive again, I realized Docker needed to be restarted in order to initialize everything again. At this point I was able to remove containers (docker rm -f).

Maybe its not the same situation, but restarting Docker is a useful thing to try.

like image 132
jersey bean Avatar answered Oct 12 '22 12:10

jersey bean


While browsing related issues, I found something similar "Driver aufs failed to remove root filesystem", "device or resource busy", and at around 80% below, there was a solution which said to use docker stop cadvisor; then docker rm [dead container]

Edit 1: docker stop cadvisor instead of docker stop deadContainerId

like image 42
Ayushya Avatar answered Oct 12 '22 12:10

Ayushya


As the error message states, docker was configured to use AUFS as storage driver, but they recommend to use Overlay2 instead, as you can read on this link: https://github.com/moby/moby/issues/21704#issuecomment-312934372

So I changed my configuration to use Overlay2 as docker storage driver. When we do that it removes EVERYTHING from old storage drive, it means that my "Dead" container was gone also.

It is not exactly a solution for my original question, but the result was accomplished.

like image 2
Azize Avatar answered Oct 12 '22 11:10

Azize