docker ps -aq
Shows only 7-9 images.
/var/lib/docker/graph
shows me n number of images.
When I create a file, I get write error due to system full error. I tried to create symbolic link. but I cannot able to move all the docker things.
Is it good to remove everything under /var/lib/docker/graph? What are the other possibilities than creating symbolic link and extending disk? I would prefer deleting unnecessary things.
<none> <none> 02a16288ef14 6 days ago 773.3 MB
<none> <none> 21a606deee7e 6 days ago 773.3 MB
<none> <none> 8a38f2888018 6 days ago 773.2 MB
<none> <none> f41395b7637d 6 days ago 773.3 MB
<none> <none> 8b82d707167c 6 days ago 773.3 MB
To get rid of "dangling" images, run the following:
$ docker rmi $(docker images -q -f dangling=true)
That should clear out all the images marked "none". Be aware however, that images will share base layers, so the total amount of diskspace used by Docker will be considerably less than what you get by adding up the sizes of all your images.
Use docker ps -a to get the container ID and image ID. You can remove the container with
docker rm <containerID>
Then you can remove the image with
docker rmi <imageID>
According to the answer given here,
/var/lib/docker/aufs/diff/ has the file contents of the images.
/var/lib/docker/graph/ now only contains metadata about the
image, in the json and layersize files.
/var/lib/docker/repositories-aufs is a JSON file containing local
image information. This can be viewed with the command docker images.
Refer to this link, Docker containers can be stopped and deleted by the following commands
docker ps
docker stop
docker rm containerid
docker rmi imageid
I faced the similar issue running out of space. Then I realized that dangling docker volumes are eating up space.
You can delete the dangling docker volumes with the following command
docker volume rm $(docker volume ls -qf dangling=true)
Related
I believe I have tried every command recommended to remove the last few images from my sever, but I can't get rid of them.
I'm considering uninstalling docker and then remove /var/lib/docker and finally reinstalling docker.
Would that work?
Here's what I've been trying.
[root#s-app-t54 docker]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root#jenkins-agent-1 docker]# docker -v
Docker version 20.10.13, build a224086
[root#s-app-t54 docker]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root#jenkins-agent-1 docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis 6.0.10 621ceef7494a 14 months ago 104MB
tomcat 8.5 37bdd9cb0d0e 14 months ago 533MB
adoptopenjdk/openjdk8-openj9 jdk8u275-b01_openj9-0.23.0-alpine-slim 440045c41637 15 months ago 142MB
busybox latest dc3bacd8b5ea 16 months ago 1.23MB
redis 6 62f1d3402b78 17 months ago 104MB
httpd latest 3dd970e6b110 18 months ago 138MB
redis 5 f60d84d4d72c 20 months ago 98.3MB
stilliard/pure-ftpd latest 07037e0784e0 23 months ago 169MB
redis latest de25a81a5a0b 2 years ago 98.2MB
[root#jenkins-agent-1 docker]# docker volume ls
DRIVER VOLUME NAME
[root#jenkins-agent-1 docker]# docker rmi -f 621ceef7494a 37bdd9cb0d0e 440045c41637 \
dc3bacd8b5ea 62f1d3402b78 3dd970e6b110 f60d84d4d72c 07037e0784e0 de25a81a5a0b
Error: No such image: 621ceef7494a
Error: No such image: 37bdd9cb0d0e
Error: No such image: 440045c41637
Error: No such image: dc3bacd8b5ea
Error: No such image: 62f1d3402b78
Error: No such image: 3dd970e6b110
Error: No such image: f60d84d4d72c
Error: No such image: 07037e0784e0
Error: No such image: de25a81a5a0b
[root#jenkins-agent-1 docker]# docker system prune -a --volumes
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all volumes not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B
[root#jenkins-agent-1 docker]#
What will make it work will depend on what is actually causing the problem. But here are some possible solutions:
Solution 1: Restart the docker daemon:
# in case you are using Linux
sudo systemctl stop docker
sudo systemctl start docker
and then try to remove the images once again after that.
Solution 2: Try to remove the images as pointed out in this article
Solution 3: If nothing of that works, take a look at some answers replied on this other question. The accepted answer there has some side effects (read the comments related to it before doing that).
Try:- docker rmi -f $(docker image ls)
If it still says Error: No such image , then most probably your images are removed and you can verify again with: docker image ls
Edit - 1 :
I found the problem , sometimes the stopped containers store the images being used to create them.
First remove all the containers with : docker rm -f $(docker ps -a -q)
Then remove all the docker images with : docker rmi -f $(docker image ls)
I have docker installed on my mac and when I do docker info I see this information:
Containers: 9
Running: 8
Paused: 0
Stopped: 1
Images: 5
But, when I run docker container ls -a or docker ps -a Then I see nothing running there.
I can see the 5 running Images when I do this: docker images -a ,
REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-apiserver-amd64 v1.10.11 e851a7aeb6e8 3 months ago 228MB
k8s.gcr.io/kube-controller-manager-amd64 v1.10.11 978cfa2028bf 3 months ago 151MB
k8s.gcr.io/kube-scheduler-amd64 v1.10.11 d2c751d562c6 3 months ago 51.2MB
k8s.gcr.io/etcd-amd64 3.1.12 52920ad46f5b 11 months ago 193MB
k8s.gcr.io/pause-amd64 3.1 da86e6ba6ca1 14 months ago 742kB
But I'm unable to delete them.
I tried doing this: docker rmi <image_id> or even this: docker rmi $(docker images -aq)
both gave errors like this:
Error response from daemon: conflict: unable to delete <image_id> (cannot be forced) - image is being used by running container <container_id>
When I try to kill one of these "running" container IDs, like this: docker kill <container_id>, I get the error:
Error response from daemon: Cannot kill container: <container_id>: Container <long_container_id> is not running
Or, if I do docker stop <container_id> then I just get back the container ID meaning the container is already stopped I guess? and yet even After that, trying to remove the images, gives the same error.
So, how do I get rid of these running "ghost" containers and images?
if you don't need the container, you can remove the container the same way you would the image
docker rm <container_id>
then after that you should have better luck removing the image
docker rmi <image_id>
or as you had to remove all images
docker rmi $(docker images -qa)
I am using docker 1.12.5 as below:
$ docker --version
Docker version 1.12.5, build 7392c3b
I have below images:
$ docker images|grep 5000
hoth.southbanksoftware.com:5000/dbenvy-controller <none> d1e229866063 4 days ago 919.4 MB
I use below command to remove this image but failed:
$ docker rmi -f hoth.southbanksoftware.com:5000/dbenvy-controller
Error response from daemon: No such image: hoth.southbanksoftware.com:5000/dbenvy-controller:latest
It failed since the tag is not latest. Then I tried to remove it by id:
$ docker rmi -f d1e229866063
Error response from daemon: conflict: unable to delete d1e229866063 (cannot be forced) - image has dependent child images
it shows that there is dependent child images. Then how can I remove this image and its child images?
EDIT1
After following this link docker how can I get the list of dependent child images?, I did remove some images but below images still left and not able to delete.
$ docker images |grep 5000
hoth.southbanksoftware.com:5000/dbenvy-controller <none> 4074bfc5705b 3 weeks ago 667.8 MB
hoth.southbanksoftware.com:5000/ubuntu_jdk8 <none> 4074bfc5705b 3 weeks ago 667.8 MB
Below is the child images of this image id 4074bfc5705b:
$ docker images --filter since=4074bfc5705b
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 315ce2f11b01 4 days ago 667.8 MB
mysql latest 594dc21de8de 9 days ago 400.2 MB
mongo latest 86e302671af4 3 weeks ago 401.9 MB
What I don't understand is that why mysql and mongo docker images are listed there. They were created by docker pull command directly. How come they become a child image?
Docker images are created in layers, with each layer appearing as another image. You can run a docker inspect on the image you want to delete, and then run an inspect on other images on the same hosts to see which images are based on this unnamed image.
Note that this image could be something like Debian itself, with other images using it as the base. Also note that this image isn't taking up any space that wouldn't be taken by the child images, each layer only ever exists once on the drive.
I noticed that Docker appears to be using a large amount of disk space. I can see the directory /Users/me/.docker/machine/machines/default is 27.4GB
I recently cleaned up all of the images and containers I wasn't using. Now, when I run docker ps I see that no images are running.
~ $ docker ps
I can also see that I have 2 containers available.
~ $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
42332s42d3 cds-abm "/bin/bash" 2 weeks ago Exited (130) 2 weeks ago evil_shockley
9ssd64ee41 tes-abm "/bin/bash" 2 weeks ago Exited (130) 2 weeks ago lonely_brattain
I can then see I have 3 images.
~ $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ghr/get latest 6708fffdd4dfa 2 weeks ago 2.428 GB
<none> <none> 96c5974ddse18 2 weeks ago 2.428 GB
fdbh/ere latest bf1da53766b1 2 weeks ago 2.225 GB
How can these be taking up nearly 30GB?
It is because you are not removing the volumes created by the containers when you stop the container. In the future, use -v when you remove the containers.
docker rm -v <container-id>
Regrading cleaning up the space, you have to ssh into docker-machine and remove all volumes created. To do so,
docker-machine ssh default
sudo -i # You may not get permission to enter in to volumes directory
cd /var/lib/docker/volumes
rm -rf *
Make sure none of your containers are currently running. Also, make sure that you don't need any of these volumes for later use (like DB containers).
I am unable to explicitly delete some untagged docker images. Specifically, those with the tag <none>.
If I run docker images -a I get something like this:
<none> <none> 91e54dfb1179 3 months ago 188.3 MB
<none> <none> d74508fb6632 3 months ago 188.3 MB
<none> <none> c22013c84729 3 months ago 188.3 MB
<none> <none> d3a1f33e8a5a 3 months ago 188.1 MB
<none> <none> 4a5e6db8c069 3 months ago 125.1 MB
<none> <none> 2c49f83e0b13 3 months ago
However, when I type docker rmi -f 2c49f83e0b13 I get:
Error response from daemon: Conflict, 2c49f83e0b13wasn't deleted
Error: failed to remove images: [2c49f83e0b13]
Any idea what could be the problem?
These might be intermediary docker images for some images I'm actually using. But if that's the case, then the completed docker images should already have those prior images and I don't explicitly need those intermediary images to be there.
Make sure the image is actually dangling (meaning it is not referenced by any other image, or is not parent of an image)
docker images --filter "dangling=true" -q --no-trunc
If it is dangling (and should be removed), then there is a couple of pending bug reporting the impossibility to delete such images: issue 13625, issue 12487.
The container should be stopped first before you can remove the image :
docker rm $(docker ps -a -q)
Source : https://github.com/docker/docker/pull/6112
It happen to me also and restarting the docker engine and all the containers using this image solve the issue.