Issues with Docker
Issue
Dead container cannot be deleted.
Solution
Method 1
If you see the error message something like this:
Error response from daemon: Cannot destroy container elated_wozniak: Driver devicemapper failed to remove root filesystem 656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3: Device is Busy |
---|
Restart:
$ umount /var/lib/docker/devicemapper/mnt/656cfd09aee399c8ae8c8d3e735fe48d70be6672773616e15579c8de18e2a3b3
Method 2
You can delete dead containers with the command:
$ docker rm $(docker ps --all -q -f status=dead)
Method 3
Error:
Error response from daemon: driver "overlay" failed to remove root filesystem for |
---|
- Check what other processes also use docker resources:
$ grep docker /proc/*/mountinfo
- Find the process, that will output something like the following, where the figure after /proc/ equals pid:
/proc/10001/mountinfo:179... /proc/10002/mountinfo:149... /proc/12345/mountinfo:159 149 0:36 / /var/lib/docker/overlay/...
- Check the process name above pid:
$ ps -p 10001 -o comm= dockerd $ ps -p 10002 -o comm= docker-containe $ ps -p 12345 -o comm= nginx <<<-- This is suspicious!!!
- Nginx with pid 12345 also uses /var/lib/docker/overlay/... so we cannot delete the associated container and get the error device or resource busy.
- Stop Nginx:
$ service nginx stop
- Delete the container:
$ docker rm <container-id>
- Start the process:
$ service nginx start
We recommend that you restart the system if there are many processes.