Clean Docker /var/lib/docker/devicemapper - docker

Hello does anyone know how to clean docker devicemapper file ?
I've already cleaned all the images / containers but still the device mapper file is abnormally big:
docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab/gitlab-ce latest 735fdb05ad5d 27 hours ago 1.225 GB
<none> <none> 06fefa4a9183 6 weeks ago 1.077 GB
rancher/agent-instance v0.6.0 134980b9bbfb 6 months ago 635.6 MB
<none> <none> 06d5beefe33e 6 months ago 635.6 MB
<none> <none> e172255e7648 6 months ago 495.6 MB
<none> <none> c20ca66652e8 6 months ago 495.6 MB
<none> <none> e736ae48fd3a 6 months ago 483.8 MB
<none> <none> 8239904dd749 6 months ago 472.1 MB
<none> <none> b780de634713 6 months ago 472.1 MB
<none> <none> eda17c9d109e 6 months ago 472.1 MB
<none> <none> 2ec6b457b5d8 6 months ago 300.6 MB
<none> <none> a15c0b4b75b1 6 months ago 300.6 MB
<none> <none> b6501c507a32 6 months ago 300.1 MB
rancher/agent v0.8.2 4de7ef5d11e3 8 months ago 365 MB
<none> <none> a0ff15f1f8ad 8 months ago 365 MB
<none> <none> 4bb3b77da9b1 8 months ago 365 MB
<none> <none> 8410b01d3f42 8 months ago 365 MB
<none> <none> 4068f49bc382 9 months ago 365 MB
<none> <none> 2a6ec0cadaec 9 months ago 365 MB
<none> <none> 8ca7bc756812 9 months ago 342.4 MB
<none> <none> b6cc9819d3f4 9 months ago 321.4 MB
<none> <none> d760275f41ff 9 months ago 306 MB
<none> <none> 1c524e41e113 9 months ago 305.5 MB
<none> <none> 4bec63e16966 9 months ago 260.8 MB
<none> <none> 574422a69939 9 months ago 256.7 MB
<none> <none> d5ddd9bb3635 9 months ago 247.2 MB
<none> <none> 44ae5d2a191e 9 months ago 188.3 MB
<none> <none> 62df8e845c12 9 months ago 188.3 MB
<none> <none> b6a4b778253d 9 months ago 188.3 MB
<none> <none> 7d8a588d75a5 9 months ago 188.1 MB
<none> <none> 3f55b715e2c4 2 years ago 299.7 MB
<none> <none> 1bc5ec756ec9 2 years ago 192.6 MB
<none> <none> 3463aff75755 2 years ago 192.7 MB
<none> <none> 1013ce565837 2 years ago 192.6 MB
<none> <none> 5806993e4389 2 years ago 192.6 MB
<none> <none> bd64f000e711 2 years ago 192.6 MB
<none> <none> e73baccf8d9e 2 years ago 192.6 MB
<none> <none> 6b7491a446ad 2 years ago 192.6 MB
<none> <none> c2910096a074 2 years ago 192.5 MB
<none> <none> cf2172af6603 2 years ago 192.5 MB
Images sums up to roughly 15gb while the devicemapper file is 30GB !
There is only one container running the will take at max another 1gb.
Is there a way to reduce it to a proper size WITHOUT having to remove docker and reinstall from stratch ? Something like a garbage collection tool to be executed once in a while ?

use following command:
docker rm -v $(docker ps -a -q -f status=exited)

Related

docker images show only None

After relocate the docker image folder, I saw all of them become :
<none> <none> 12069d4ba8d4 13 months ago 7.19GB
<none> <none> 519d8684c235 20 months ago 5.93GB
<none> <none> 12764c392d35 20 months ago 3.77GB
<none> <none> 1c4919a8822c 20 months ago 111MB
<none> <none> a0d006d9b891 20 months ago 129MB
<none> <none> d87ab6bd211a 20 months ago 2.9GB
<none> <none> 10b8f2a80a31 20 months ago 1.85GB
<none> <none> f643c72bc252 22 months ago 72.9MB
<none> <none> caaeaf912e18 2 years ago 1.96GB
<none> <none> c165f07c5dfb 3 years ago 4.47GB
<none> <none> 7682fa2ad1a5 3 years ago 1.53GB
<none> <none> 4ab4c602aa5e 4 years ago 1.84kB
<none> <none> a6e93ac09154 4 years ago 1.78GB
They are still usable but all the names and tags are gone. How to recover them?

Docker disk memory : can I remove intermediate images?

I'm running out of disk memory.
If I run docker images, I get a lot of results:
app_mongodb latest 355f8f37c385 17 hours ago 568.1 MB
app_web latest a31db2244a8b 18 hours ago 868.2 MB
<none> <none> 71e586165d46 18 hours ago 568.1 MB
<none> <none> 422c281541d3 18 hours ago 568.1 MB
<none> <none> 1b16da634fa1 18 hours ago 535.4 MB
website_web latest e4442589e2f4 2 days ago 793.6 MB
<none> <none> 5445f9b915e6 3 days ago 535.4 MB
<none> <none> e825b94d5938 3 days ago 868 MB
<none> <none> ea1ddc53d17f 3 days ago 535.4 MB
<none> <none> 90531b8bd2d3 5 days ago 855.6 MB
<none> <none> 774895648397 5 days ago 535.4 MB
<none> <none> 0f474dc179c4 5 days ago 855.6 MB
<none> <none> 37cd4d180580 5 days ago 535.4 MB
<none> <none> 5f701c2e3fac 5 days ago 535.4 MB
<none> <none> 6837158ac191 5 days ago 535.4 MB
<none> <none> f3eecd70620e 5 days ago 535.4 MB
<none> <none> 27b3e1701f05 5 days ago 535.4 MB
<none> <none> 64763f09b1d4 5 days ago 535.4 MB
<none> <none> b58542e468e6 5 days ago 855.6 MB
app2_web latest 01c45018b686 5 days ago 645.5 MB
redis latest e4a35914679d 11 days ago 182.9 MB
<none> <none> 8d6737f884f8 12 days ago 854.7 MB
<none> <none> 27f7742e8b2b 2 weeks ago 792.1 MB
api_web latest 59ec56265675 2 weeks ago 906.4 MB
<none> <none> 33c328f5a271 2 weeks ago 782.2 MB
<none> <none> 53d4ad25e6c2 2 weeks ago 782.1 MB
<none> <none> 01ac14f597ba 2 weeks ago 854 MB
app3_web latest 2aaa4675cc58 3 weeks ago 929.9 MB
<none> <none> bde15910281e 3 weeks ago 789.5 MB
postgres latest ecd991538a0f 4 weeks ago 265.5 MB
app4_web latest c8b0de070d78 7 weeks ago 1.088 GB
<none> <none> 67e3ef67081b 7 weeks ago 859.2 MB
<none> <none> 451229f8dedb 7 weeks ago 859.2 MB
server_web latest 72bd5165f262 9 weeks ago 665.4 MB
<none> <none> c7f0d2b67986 9 weeks ago 660.9 MB
app5_web latest 7477b8e5ef63 3 months ago 690 MB
<none> <none> ee7de82e0cf0 3 months ago 856.7 MB
mdillon/postgis latest ee2a84576d15 3 months ago 600.2 MB
<none> <none> d8ee634a8581 4 months ago 685.3 MB
memcached latest 5fdd5c36cc9a 4 months ago 126.1 MB
app6_web latest 813fb5eac7d1 5 months ago 823.7 MB
app7_web latest 3b6a87b67359 5 months ago 645.5 MB
node argon 3b6a87b67359 5 months ago 645.5 MB
mongo latest 48b8b08dca4d 6 months ago 366.4 MB
ruby 2.2.1 aca1c061bdd2 23 months ago 775.1 MB
I know what all the named dockers correspond to, I can easily manage them and remove those I don't need anymore. But they are not majority!
Regarding the other ones, I guess they are intermediate dockers.
I wonder if I remove those, will the named one be broken or it's simply that if I rebuild them (eg. with the --no-cache option), docker will have to re-download them? (which is fine)
Eg. Does a docker based on the ruby one needs it to start or only to build?
These are probably images you built in the past, but then when you rebuilt the image, the relevant tag moved to another image, leaving these images untagged. Thus they show up as <none> <none>.
Looking at a sampling of your output, I'd guess a lot of them are old builds of app_mongodb:latest and app_web:latest. Based on the sizes.
app_mongodb latest 355f8f37c385 17 hours ago 568.1 MB
app_web latest a31db2244a8b 18 hours ago 868.2 MB
<none> <none> 71e586165d46 18 hours ago 568.1 MB
<none> <none> 422c281541d3 18 hours ago 568.1 MB
<none> <none> 1b16da634fa1 18 hours ago 535.4 MB
website_web latest e4442589e2f4 2 days ago 793.6 MB
<none> <none> 5445f9b915e6 3 days ago 535.4 MB
<none> <none> e825b94d5938 3 days ago 868 MB
<none> <none> ea1ddc53d17f 3 days ago 535.4 MB
<none> <none> 90531b8bd2d3 5 days ago 855.6 MB
<none> <none> 774895648397 5 days ago 535.4 MB
<none> <none> 0f474dc179c4 5 days ago 855.6 MB
<none> <none> 37cd4d180580 5 days ago 535.4 MB
<none> <none> 5f701c2e3fac 5 days ago 535.4 MB
<none> <none> 6837158ac191 5 days ago 535.4 MB
<none> <none> f3eecd70620e 5 days ago 535.4 MB
<none> <none> 27b3e1701f05 5 days ago 535.4 MB
<none> <none> 64763f09b1d4 5 days ago 535.4 MB
<none> <none> b58542e468e6 5 days ago 855.6 MB
It is most likely safe to delete them. If you try to delete them and they are being used by a container or another image, then Docker will complain about that.
In recent versions of Docker (I believe >= 1.13) you can use the prune command to clean up images not referenced by an image or container.
docker image prune
in the newer docker versions, you can simply do:
docker image prune
refer to: https://docs.docker.com/engine/reference/commandline/image_prune/#description
Using docker images -f dangling=true -q we can find <none><none> images. Then we can delete them using below command,
docker rmi -f $(docker images -f dangling=true -q --no-trunc)
We may need -f option to delete them forcefully.

Removing docker image errors "No such id" with a different image ID

parallels#ubuntu:~$ sudo docker images
[sudo] password for parallels:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.10 525b6e4a4cc8 6 days ago 194.4 MB
<none> <none> 4faa69f72743 6 days ago 188.3 MB
<none> <none> 78949b1e1cfd 3 weeks ago 194.4 MB
<none> <none> 2d24f826cb16 3 weeks ago 188.3 MB
<none> <none> 1f80e9ca2ac3 3 weeks ago 131.5 MB
<none> <none> 5ba9dab47459 6 weeks ago 188.3 MB
<none> <none> c5881f11ded9 9 months ago 172.2 MB
<none> <none> 463ff6be4238 9 months ago 169.4 MB
<none> <none> 195eb90b5349 9 months ago 184.7 MB
<none> <none> 3db9c44f4520 10 months ago 183 MB
parallels#ubuntu:~$ sudo docker rmi 4faa69f72743
Error response from daemon: No such id: 2103b00b3fdf1d26a86aded36ae73c1c425def0f779a6e69073b3b77377df348
2015/03/16 20:32:38 Error: failed to remove one or more images
parallels#ubuntu:~$
Here, you can see that I've tried to remove 4faa69f72743. However, docker insists that I am trying to remove 2103b00..., and errors out because such image doesn't exist.
What could possibly cause this?
I don't understand the cause of it, but I've found a solution.
Here, docker ps -a shows exited containers with the image ID matching the problem hash.
parallels#ubuntu:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
parallels#ubuntu:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1c538a69a522 2103b00b3fdf bash 3 hours ago Exited (-1) 3 hours ago sharp_mccarthy
d9b683ddec73 2103b00b3fdf bash 3 hours ago Exited (0) 3 hours ago nostalgic_davinci
fcf8f628066f 2103b00b3fdf bash 3 hours ago Exited (0) 3 hours ago drunk_rosalind
06591014c89a 2103b00b3fdf sleep 10 3 hours ago Exited (0) 3 hours ago sleepy_goldstine
cb54fe012231 2103b00b3fdf sleep 10 3 hours ago Exited (0) 3 hours ago compassionate_leakey
de9cc4cbefe5 2103b00b3fdf sleep 10 3 hours ago Exited (0) 3 hours ago agitated_brattain
0ac0e70451cd 2103b00b3fdf ps -a 3 hours ago Exited (1) 3 hours ago berserk_goldstine
a6cc821ab7a4 2103b00b3fdf whoami 3 hours ago Exited (0) 3 hours ago distracted_pare
89f0c413787a ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago silly_hawking
5388489a2df2 ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago pensive_wozniak
1a060874271f ubuntu:14.10 pwd 3 hours ago Exited (0) 3 hours ago determined_goldstine
5bf4d049e3d2 ubuntu:14.10 pwd 3 hours ago Exited (0) 3 hours ago angry_hypatia
2033e10cb026 ubuntu:14.10 ls 3 hours ago Exited (0) 3 hours ago desperate_poincare
54f6f631cf17 ubuntu:14.10 ls 3 hours ago Exited (0) 3 hours ago cranky_davinci
c44eb12aeedf ubuntu:14.10 bash 3 hours ago Exited (0) 3 hours ago high_darwin
64f14a9cf537 ubuntu:14.10 ps 3 hours ago Exited (0) 3 hours ago goofy_morse
4b8f2516ddbd ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago high_ardinghelli
0e3a3a6a8582 ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago dreamy_turing
49397f5bf47f ubuntu:14.10 ls 3 hours ago Exited (0) 3 hours ago grave_hoover
Trying to remove the image was unsuccessful.
parallels#ubuntu:~$ sudo docker rmi 2103b00b3fdf
Error response from daemon: No such image: 2103b00b3fdf
2015/03/16 22:35:45 Error: failed to remove one or more images
However, I was able to remove the containers that were associated with the image.
parallels#ubuntu:~$ sudo docker rm 1c538
1c538
parallels#ubuntu:~$ sudo docker rm d9b fcf 065 cb5 de9 0ac a6c
d9b
fcf
065
cb5
de9
0ac
a6c
parallels#ubuntu:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
parallels#ubuntu:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
89f0c413787a ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago silly_hawking
5388489a2df2 ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago pensive_wozniak
1a060874271f ubuntu:14.10 pwd 3 hours ago Exited (0) 3 hours ago determined_goldstine
5bf4d049e3d2 ubuntu:14.10 pwd 3 hours ago Exited (0) 3 hours ago angry_hypatia
2033e10cb026 ubuntu:14.10 ls 3 hours ago Exited (0) 3 hours ago desperate_poincare
54f6f631cf17 ubuntu:14.10 ls 3 hours ago Exited (0) 3 hours ago cranky_davinci
c44eb12aeedf ubuntu:14.10 bash 3 hours ago Exited (0) 3 hours ago high_darwin
64f14a9cf537 ubuntu:14.10 ps 3 hours ago Exited (0) 3 hours ago goofy_morse
4b8f2516ddbd ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago high_ardinghelli
0e3a3a6a8582 ubuntu:14.10 whoami 3 hours ago Exited (0) 3 hours ago dreamy_turing
49397f5bf47f ubuntu:14.10 ls 3 hours ago Exited (0) 3 hours ago grave_hoover
Finally, with the containers removed, I was able to remove the unused images.
parallels#ubuntu:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.10 525b6e4a4cc8 6 days ago 194.4 MB
<none> <none> 4faa69f72743 6 days ago 188.3 MB
<none> <none> 78949b1e1cfd 3 weeks ago 194.4 MB
<none> <none> 2d24f826cb16 3 weeks ago 188.3 MB
<none> <none> 1f80e9ca2ac3 3 weeks ago 131.5 MB
<none> <none> 5ba9dab47459 6 weeks ago 188.3 MB
<none> <none> c5881f11ded9 9 months ago 172.2 MB
<none> <none> 463ff6be4238 9 months ago 169.4 MB
<none> <none> 195eb90b5349 9 months ago 184.7 MB
<none> <none> 3db9c44f4520 10 months ago 183 MB
parallels#ubuntu:~$ sudo docker rmi 4faa
Deleted: 4faa69f72743ce3a18508e840ff84598952fc05bd1de5fd54c6bc0f8ca835884
Deleted: 76b658ecb5644a4aca23b35de695803ad2e223da087d4f8015016021bd970169
Deleted: f0dde87450ec8236a64aebd3e8b499fe2772fca5e837ecbfa97bd8ae380c605e
parallels#ubuntu:~$
Hooray, unexplainable problems and solutions!

Docker pull not getting image tagnames

I'm running docker with boot2docker on OS X 10.10.
I'm following the main tutorial and doing a docker pull ubuntu
It gets the image okay, however when I then do docker images it only lists ubuntu:latest
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest 5506de2b643b 3 weeks ago 199.3 MB
instead of the full list of images as the tutorial says:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
training/webapp latest fc77f57ad303 3 weeks ago 280.5 MB
ubuntu 13.10 5e019ab7bf6d 4 weeks ago 180 MB
ubuntu saucy 5e019ab7bf6d 4 weeks ago 180 MB
ubuntu 12.04 74fe38d11401 4 weeks ago 209.6 MB
ubuntu precise 74fe38d11401 4 weeks ago 209.6 MB
ubuntu 12.10 a7cf8ae4e998 4 weeks ago 171.3 MB
ubuntu quantal a7cf8ae4e998 4 weeks ago 171.3 MB
ubuntu 14.04 99ec81b80c55 4 weeks ago 266 MB
ubuntu latest 99ec81b80c55 4 weeks ago 266 MB
ubuntu trusty 99ec81b80c55 4 weeks ago 266 MB
ubuntu 13.04 316b678ddf48 4 weeks ago 169.4 MB
ubuntu raring 316b678ddf48 4 weeks ago 169.4 MB
ubuntu 10.04 3db9c44f4520 4 weeks ago 183 MB
ubuntu lucid 3db9c44f4520 4 weeks ago 183 MB
If I do docker images -a I see this:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest 5506de2b643b 3 weeks ago 199.3 MB
<none> <none> 22093c35d77b 3 weeks ago 199.3 MB
<none> <none> 3680052c0f5c 3 weeks ago 192.7 MB
<none> <none> e791be0477f2 3 weeks ago 192.7 MB
<none> <none> ccb62158e970 3 weeks ago 192.7 MB
<none> <none> d497ad3926c8 3 weeks ago 192.5 MB
<none> <none> 511136ea3c5a 17 months ago 0 B
Anybody knows why this is happening?
When you do a docker pull <image> you will only get the latest tag for that image. This is expected behaviour.
To pull a specific tag, use docker pull <image>:<tag>.
The list there in the documentation should only be expected if you've followed the full guide and used all those images. You usually only need one tag for an image.

Why the images information provided by docker info is different from docker images

Hi I'm trying to extract the number of docker images I have in my machine
If I run the command docker info it gives me this:
Containers: 15
Images: 27
Driver: aufs
Root Dir: /var/lib/docker/aufs
Dirs: 57
Username: miggom
Registry: [https://index.docker.io/v1/]
WARNING: No swap limit support
If I run the command docker images -a it gives me this:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 2b1cf54887a8 20 minutes ago 139.5 MB
<none> <none> 14e148a673c8 3 hours ago 204.4 MB
<none> <none> bf3d7d4f575d 13 days ago 273.9 MB
<none> <none> c3553dd60b1e 13 days ago 273.9 MB
mgs/my-site latest 268ffd69fb60 13 days ago 273.9 MB
miggom/mySite latest 268ffd69fb60 13 days ago 273.9 MB
my-site latest 268ffd69fb60 13 days ago 273.9 MB
mgsMySite latest 268ffd69fb60 13 days ago 273.9 MB
mgs_mySite latest 268ffd69fb60 13 days ago 273.9 MB
<none> <none> b055dfd3f223 13 days ago 273.9 MB
apache2 latest 826c4bc6368a 2 weeks ago 273.9 MB
<none> <none> 7aa770719eb1 2 weeks ago 273.9 MB
<none> <none> 1850570b7316 2 weeks ago 273.9 MB
<none> <none> 44943615dd35 2 weeks ago 273.9 MB
<none> <none> 994c3e50a608 2 weeks ago 273.9 MB
<none> <none> a97583e98230 2 weeks ago 273.9 MB
<none> <none> 635d880c0c38 2 weeks ago 273.9 MB
<none> <none> b8735e7272ef 2 weeks ago 224.3 MB
baselDaemon latest 4e892058b0b2 2 weeks ago 204.4 MB
ubuntu saucy 9f676bd305a4 4 weeks ago 178 MB
ubuntu 13.10 9f676bd305a4 4 weeks ago 178 MB
<none> <none> 1c7f181e78b9 4 weeks ago 0 B
ubuntu 13.04 eb601b8965b8 4 weeks ago 166.5 MB
ubuntu raring eb601b8965b8 4 weeks ago 166.5 MB
<none> <none> f323cf34fd77 4 weeks ago 0 B
ubuntu 12.10 5ac751e8d623 4 weeks ago 161 MB
ubuntu quantal 5ac751e8d623 4 weeks ago 161 MB
<none> <none> 321f7f4200f4 4 weeks ago 0 B
ubuntu 10.04 9cc9ea5ea540 4 weeks ago 180.8 MB
ubuntu lucid 9cc9ea5ea540 4 weeks ago 180.8 MB
ubuntu precise 9cd978db300e 4 weeks ago 204.4 MB
ubuntu 12.04 9cd978db300e 4 weeks ago 204.4 MB
ubuntu latest 9cd978db300e 4 weeks ago 204.4 MB
<none> <none> 6170bb7b0ad1 4 weeks ago 0 B
<none> <none> 7a4f87241845 5 weeks ago 0 B
<none> <none> 511136ea3c5a 8 months ago 0 B
learn/tutorial latest 8dbd9e392a96 10 months ago 128 MB
So, the problem is that the number of the images shown in docker info doesn't match with the number of images shown in docker images. I don't know how to get the correct number of images beacuse if you also execute the docker images without flags, it doesn't match with the number of images shown in docker info
I don't know which type of information I can get from docker info because in docker.io there is just an example of the documentation.
Thank you in advance
The point here is not whether an image is flagged or not. Take note of the Image ID when you count the images. Several (differently tagged) images with the same ID count as one image, because well... they are the same image :)
If I manually count the different IDs, I find 27.
A lot of those images are intermediary images and are used for caching when you want to rebuild your Dockerfile.
By default when you run docker images it hides these intermediate images, but if you pass the -a argument it'll show them all

Resources