Docker Community Forums

Share and learn in the Docker community.

Is Docker System Prune safe to be used on a Production machine?

Hi! We have a Virtual Machine with Docker installed and we have some containers/images/volumes. We are running Jenkins and Rancher as well.

We have been problems with disk space and we just noticed that the docker folder is taking almost all the disk space.

By doing

docker ps
docker images
docker volume ls

everything seems to be okay. I can’t see anything that shouldn’t be there.

After running docker system df, it shows:

Images - Size 3.358GB (Reclaimable 28%)
Containers- Size 46.66MB (Reclaimable 0%)
Local Volumes- Size 44.32MB (Reclaimable 0%)

There is only 28% fo reclaimable disk space. We can also see that Images, Containers and Volumes are taking up to around 3.5GB.

However, when I do sudo du --max-depth=1 -h | sudo sort -n -r | sudo head -n 20 on /var/lib/docker

docker%20space

we can see that ./aufs is taking 8.7GB.

Is it secure to do docker system prune? Will this command free some space from that ./aufs folder?
Will that command remove, for example, meltwater/docker-cleanup container/image?

And another question, which I don’t know if it’s related to Docker: there is an export folder on the root of the machine. Is it related to Docker whatsoever?

Thanks a lot for the help.

docker system prune is not safe to be used in production.

It may clean up and reclaim space but there’s a possibility that one or more containers will die and need to be restarted manually.

In production apps, you want the images to fail gracefully and restart automatically.

$ 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

Deleted Containers:
0998aa37185a1a7036b0e12cf1ac1b6442dcfa30a5c9650a42ed5010046f195b
73958bfb884fa81fa4cc6baf61055667e940ea2357b4036acbbe25a60f442a4d

Deleted Networks:
my-network-a
my-network-b

Deleted Volumes:
named-vol

Deleted Images:
untagged: my-curl:latest
deleted: sha256:7d88582121f2a29031d92017754d62a0d1a215c97e8f0106c586546e7404447d
deleted: sha256:dd14a93d83593d4024152f85d7c63f76aaa4e73e228377ba1d130ef5149f4d8b
untagged: alpine:3.3
deleted: sha256:695f3d04125db3266d4ab7bbb3c6b23aa4293923e762aa2562c54f49a28f009f
untagged: alpine:latest
deleted: sha256:ee4603260daafe1a8c2f3b78fd760922918ab2441cbb2853ed5c439e59c52f96
deleted: sha256:9007f5987db353ec398a223bc5a135c5a9601798ba20a1abba537ea2f8ac765f
deleted: sha256:71fa90c8f04769c9721459d5aa0936db640b92c8c91c9b589b54abd412d120ab
deleted: sha256:bb1c3357b3c30ece26e6604aea7d2ec0ace4166ff34c3616701279c22444c0f3
untagged: my-jq:latest
deleted: sha256:6e66d724542af9bc4c4abf4a909791d7260b6d0110d8e220708b09e4ee1322e1
deleted: sha256:07b3fa89d4b17009eb3988dfc592c7d30ab3ba52d2007832dffcf6d40e3eda7f
deleted: sha256:3a88a5c81eb5c283e72db2dbc6d65cbfd8e80b6c89bb6e714cfaaa0eed99c548

Total reclaimed space: 13.5 MB