How To Fix The Running Out Of Disk Space Error In
- About
- Products
- Log in
-
- Home
- Questions
- Users
- Companies
- Labs
- Jobs
- Discussions
-
Recent Tags
- docker
- docker-machine
- centos
-
Collectives
- Communities for your favourite technologies. Explore all Collectives
-
Teams
Now available on Stack Overflow for Teams! AI features where you work: search, IDE, and chat.
How to fix the running out of disk space error in Docker?
Asked 6 years, 2 months ago
Modified 1 month ago
Viewed 135k times
71
When I am trying to build the docker image I am getting out of disk space error and after investigating I find the following:
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 4G 3.8G 0 100% /
How do I fix this out of space error?
asked Jul 9, 2018 at 5:46
](https://stackoverflow.com/users/1475228/pritam-banerjee)
18.8k
1010 gold badges
9696 silver badges
110110 bronze badges
-
6
There’s no error here, just the output of
df -h. Also when you say “memory” you probably mean “disk space”?– jannis
-
2
Here solution: stackoverflow.com/questions/25713773
– T.Todua
12 Answers
Sorted by:
130
docker system prune [-a]
https://docs.docker.com/engine/reference/commandline/system_prune/
This will clean up all images, containers, networks, volumes not used. We generally try to clean up old images when creating a new one but you could also have this run as a scheduled task on your docker server every day.
Other answers address listing system memory usage and increasing the amount of Docker disk space in Docker Desktop:
The
docker system dfcommand can be used to view reclaimable memory –Abishek_Jain
Open up the docker settings -> Resources -> Advanced and up the amount of Hard Drive space it can use under disk image size. –Nico
](https://stackoverflow.com/users/13969/rjurney)
5,088
55 gold badges
4242 silver badges
6464 bronze badges
answered Jul 9, 2018 at 9:55
](https://stackoverflow.com/users/1794961/nick-spicer)
2,617
44 gold badges
2222 silver badges
2626 bronze badges
-
26
You need to pass the
--volumesflag to prune the volumes as well. Without this only ‘unused containers, networks, images (both dangling and unreferenced)’ will be pruned.– jannis
-
2
I feel that this is only a temporary solution. We have over 14Gb free disk space and Docker still says that no space is left. We called “docker system prune” and it worked, but only for a while. Not to mention that the database was deleted as well but thats our fault (always make regular backups people!)
30
use command - docker system prune -a This will clean up total Reclaimable Sise for Images, Network & Volume….. This will remove all images related reclaimable space which are not associated with any running container…..
Run docker system df command to view Reclaimable memory
In case there is some Reclaimable memory then if above command does not work in first go then run the same command twice then it should cleaned up…. I have been experiencing this behaviour almost on daily basis….. Planning to report this bug to Docker Community but before that want to reproduce this bug with new release to see if this has been fixed or not with latest one….
](https://stackoverflow.com/users/2458858/tryingtolearn)
11.5k
1212 gold badges
8484 silver badges
126126 bronze badges
answered Nov 4, 2018 at 17:46
](https://stackoverflow.com/users/9819333/abhishek-jain)
4,119
22 gold badges
2929 silver badges
3030 bronze badges
-
15
Be very careful with
-a. This will wipe every image on your system that doesn’t have a container associated with it. Usually justdocker system pruneis sufficient.– Josh
-
1
I did mention about user has to be careful when using -a as it will remove all images for which containers are not running….
-
Be very careful with -a. This will also remove unused networks and you may lose network connectivity.
-
The statement “if above command does not work in first go then run the same command twice” helped me. Not sure, why it did not free up space in 1 shot.
20
Open up the docker settings -> Resources -> Advanced and up the amount of Hard Drive space it can use under disk image size.
answered Aug 4, 2020 at 14:23
](https://stackoverflow.com/users/1143358/nico)
1,162
1313 silver badges
1717 bronze badges
-
1
Works great for me on docker desktop version 2.3.0.4 on Mac os Mojave.
-
9
Is there any way to do this on Linux?
– nCoder
-
@nCoder docker does not run in a VM on (most) linux machines, so there is no artificial limitation on the amount of disk space it can use to begin with.
-
1
This should be top answer in combination with the original and second answer.
– rjurney
13
If you are using linux, then most probably docker is filling up the directory /var/lib/docker/containers, because it is writing container logs to <CONTAINER_ID>-json.log file under this directory. You can use the command cat /dev/null > <CONTAINER_ID>-json.log to clear this file or you can set the maximum log file size be editing /etc/sysconfig/docker. More information can be found in this RedHat documentation. In my case, I have created a crontab to clear the contents of the file every day at midnight. Hope this helps!
NB:
- You can find the docker containers with ID using the following command
sudo docker ps --no-trunc - You can check the size of the file using the command
du -sh $(docker inspect --format='{{.LogPath}}' CONTAINER_ID_FOUND_IN_LAST_STEP)
answered Jun 24, 2020 at 11:30
](https://stackoverflow.com/users/784929/kaushik)
2,473
66 gold badges
3838 silver badges
5353 bronze badges
-
Does Log files takes larger memory space?
– adnan
-
1
@adnan, yes, it will takeup diskspace eventually
– kaushik
-
Some linux distros it’s /var/lib/docker/overlay2
– Geordie
4
Nothing works for me. I change the disk images max size in Docker Settings, and just after that it free huge size.
answered Oct 15, 2018 at 12:24
](https://stackoverflow.com/users/471137/troger19)
1,289
22 gold badges
1515 silver badges
3131 bronze badges
-
1
Wow, I didn’t see this option! Was wondering why my Windows showed 60GB free disk space, but Docker containers said “Not enough disk space left” - I had my limit at 50GB (which was all used up) - set it to 200 and it worked!
– Alex
-
well the command should be as mentioned above, the thing is it doesnt work for me.. only manually clicking on a button
– troger19
4
Not sure if this is still relevant, but in case of docker system prune not working, and if you don’t want to go docker system prune -a, you should pick and delete images using either
docker image prune --filter
or
- Picking and deleting them from Docker for Dekstop
](https://stackoverflow.com/users/13393940/cconsta1)
807
11 gold badge
99 silver badges
2222 bronze badges
answered Apr 27, 2023 at 17:51
](https://stackoverflow.com/users/12505078/l0t)
61
44 bronze badges
3
Going to leave this here since I couldn’t find the answer.
Go to the Docker GUI -> Prefereces -> Reset -> Uninstall
Completely uninstall Docker.
Then install it fresh using this link
My docker was using 20GB of space when building an image, after fresh install, it uses 3-4GB max. Definitely helps!
Also, if you using a macbook, have look at ~/Library/Containers/docker*
This folder for me was 60 GB and was eating up all the space on my mac! Even though this may not be relevant to the question, I believe it is vital for me to leave this here.
answered Oct 11, 2019 at 9:51
](https://stackoverflow.com/users/11317776/dudanf)
2,932
11 gold badge
1515 silver badges
4444 bronze badges
-
This actually helped me a lot, thanks. I didn’t have to reinstall, but finding where all the junk data that was not getting pruned was did the trick.
1
There are at least two directories where docker can fill up space. Assuming you have a bigger disk partition on your computer, say /bigdisk, here are the possible solution:
- Temp dir in /var/tmp: docker will honour the TMPDIR settings
mkdir -p /bigdisk/bigtmp
chmod 1777 /bigdisk/bigtmp
export TMPDIR=/bigdisk/bigtmp
- /var/lib/containers (older version of docker might use /var/lib/docker). You can solve this by making /var/lib/containers to be a symlink to the bigger disk:
mkdir -p /bigdisk/var-lib/containers
ln -s /bigdisk/var-lib/containers /var/lib/containers
Now if you have already some docker images in /var/lib/containers, you need to move those first. First stop any docker daemon running
mkdir -p /bigdisk/var-lib/containers
##### copy existing container content to bigdisk
(cd /var/lib/containers; tar cvf - . ) | (cd /bigdisk/var-lib/containers; tar xvf - )
#### ensure the copy is good.
du -sh /var/lib/containers
du -sh /bigdisk/var-lib/containers
rmdir /var/lib/containers
ln -s /bigdisk/var-lib/containers /var/lib/containers
Then run docker to verify things run as before
answered May 1 at 6:47
](https://stackoverflow.com/users/21485043/monapy)
159
11 silver badge
55 bronze badges
0
I wanted to add this to my CI/CD pipeline so I won’t have to do it manually on my AWS EC2 instance.
The -f option ensured there was no prompt for confirmation
Without it, I kept getting: Are you sure you want to continue? [y/N] And my updates failed to deploy.
Here’s what worked for me: In my .yml file, :
deploy:
steps:
- name: Prune and free some space in images and containers
run: docker system prune -f
answered Feb 18 at 4:50
](https://stackoverflow.com/users/1585461/chelathegreat)
75
11 silver badge
88 bronze badges
0
Unless you are using a logging driver other than the default json_file logging driver with its default unlimited max-size, your container logs may grow large and fill up either your host machine’s disk (Linux host machine) or your docker machine VM’s disk (macOS host machine and probably also Windows). This can be hard to inspect (ref: my question).
kaushik’s answer explains how to truncate the log files on Linux. On macOS though it’s more complicated because the log files are stored in the Docker Machine VM. See my answer here for full details.
answered Feb 23 at 19:01
](https://stackoverflow.com/users/2562319/jbyler)
7,672
33 gold badges
3838 silver badges
4444 bronze badges
0
I have the same problem with my Mac. I didn’t want to remove docker and found a new way
Go to the Docker GUI -> Troubleshooting -> Reset to factory defaults
This made about 50 GB available
answered Apr 17 at 14:29
](https://stackoverflow.com/users/5382500/%d0%9f%d0%b5%d1%82%d1%80-%d0%94%d1%80%d1%83%d0%b1%d0%be%d0%b2)
81
11 gold badge
11 silver badge
66 bronze badges
0
I run following command:
docker system prune -a
answered Jul 18 at 3:57
](https://stackoverflow.com/users/3610643/m-namjo)
412
33 silver badges
1515 bronze badges
Your Answer
Sign up or log in
Sign up using Google
Sign up using Email and Password
Post as a guest
Name
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
##
Not the answer you’re looking for? Browse other questions tagged
- The Overflow Blog
-
One of the best ways to get value for AI coding tools: generating tests
- Featured on Meta
-
Join Stack Overflow’s CEO and me for the first Stack IRL Community Event in…
- What does a new user need in a homepage experience on Stack Overflow?
Linked
105How to clean Docker container logs?
6disk space is full by `vda` files, how to clear them?
-1How can I inspect the disk usage of docker container logs on macOS?
Related
743Docker error : no space left on device
3Docker run, no space left on device
152Docker Machine: No space left on device
82How can I fix Docker/Mac no space left on device error?
1docker start: no space left on device
58How can I fix ‘No space left on device’ error in Docker?
7Docker Error : no space left on device on windows
77docker no space left on device macOS
1docker load : no space left on device
1Why did my docker volume run out of disk space?
Hot Network Questions
- Is the closest diagonal state to a given state always the dephased original state?
- Why Pythagorean theorem is all about 2?
- Is there mathematical significance to the LaGuardia floor tiles?
- Maximise finds solution outside the constraint
- Why is the area covered by 1 steradian (in a sphere) circular in shape?
- Navigating career options after a disastrous PhD performance and a disappointed advisor?
- Is this map real?
- Two sisters live alone in a house after the rest of their family died
- 4/4 time change to 6/8 time
- What would the natural diet of Bigfoot be?
- Does the Supremacy Clause allow states to retain abortion rights enshrined in each states’ constitution?
- Does any row of Pascal’s triangle contain a Pythagorean triple?
- How will the Polaris Dawn cabin pressure and oxygen partial pressure dovetail with that of their EVA suits? (100% oxygen?)
- Can a V22 Osprey operate with only one propeller?
- Why do “modern” languages not provide argv and exit code in main?
- Why were there so many OSes that had the name “DOS” in them?
- jq - ip addr show in tabular format
- A journal has published an AI-generated article under my name. What to do?
- If a friend hands me a marijuana edible then dies of a heart attack am I guilty of felony murder?
- Book that features clones used for retirement
- How long should a wooden construct burn (and continue to take damage) until it burns out (and stops doing damage)
- Word switching from plural to singular when it is many?
- Electrical panel not sending 240
- Spacing between mathrel and mathord same as between mathrel and mathopen
Stack Overflow
Products
Company
Stack Exchange Network
- Technology
- Culture & recreation
- Life & arts
- Science
- Professional
- Business
- API
- Blog
Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.9.11.15092


