Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

539
Views
How to free wasted space used by docker?

I set up docker on my server. I use Jenkins for CI. Those tools are really cool. But, unfortunately, I still can't figure out how to get the wasted space back.

I tried different things proposed on the web and by using them I can only free a part of the wasted space. I need no any history and etc.

I tried different things, like rude docker rm $(docker ps -aq) and docker rmi $(docker images -q) while some of containers are running that make them prevented from deletion.

I also tried this script and similar.

#!/bin/bash

# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v

# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi

# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
  docker ps -aq | xargs docker inspect | jq -r '.[] | .Mounts | .[] | .Name | select(.)'
) | xargs -r rm -fr

I would like to expect that after first build of all images I have fixed size of the stuff by applying the clean up commands above. In other words I want the subsequent builds with clean up applied doesn't make the wasted space grow.

But anyway every execution of docker build occupies new space that I can't free up.

The directory /var/lib/docker/overlay grows up and doesn't consider my clean ups eventually.

Where am I wrong?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

In the latest versions of Docker, you can now use docker system prune command (with --all option for complete cleanup).

https://docs.docker.com/engine/reference/commandline/system_prune/

about 4 years ago · Santiago Trujillo Report

0

In order to remove volumes use:

docker volume prune

In order to remove networks use:

docker network prune

In order to remove all stopped containers use:

docker container prune

In order to remove unused images use:

docker image prune
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!