Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker disk memory : can I remove intermediate images?

Tags:

docker

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?

like image 551
Augustin Riedinger Avatar asked Mar 12 '17 14:03

Augustin Riedinger


People also ask

How do I remove intermediate docker images?

You can use docker image prune -f after building images. This command will remove any untagged docker images from your machine.

Is it safe to delete docker images?

In any case, deleting an image usually presents no issue—if you need it again, Docker can just fetch it from the remote repository.

How do I clean up my docker disk space?

A stopped container's writable layers still take up disk space. To clean this up, you can use the docker container prune command. By default, you are prompted to continue. To bypass the prompt, use the -f or --force flag.

What are docker intermediate images?

Docker images have intermediate layers that increase reusability, decrease disk usage, and speed up docker build by allowing each step to be cached. These intermediate layers are not shown by default. The SIZE is the cumulative space taken up by the image and all its parent images.


1 Answers

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
like image 166
Dan Lowe Avatar answered Sep 18 '22 14:09

Dan Lowe