I have a program I’m running in a docker container. After 10-12 hours of run, the program terminated with filesystem-related errors (FileNotFoundError, or similar).
I’m wondering if the disk space got filled up or a similar filesystem-related issue or there was a problem in my code (e.g one process deleted the file pre-maturely).
I don’t know much about docker management of files and wonder if inside docker it creates and manages its own FS or not. Here are three possibilities I’m considering and mainly wonder if #1 could be the case or not.
-
If docker manages it’s own filesystem, could it be that although disk space is available on the host machine, docker container ran out of it’s own storage space? (I’ve seen similar issues regarding running out of memory for a process that has limited memory artificially imposed using cgroups)
-
Could it be that host filesystem ran out of space and the files got corrupted or maybe didn’t get written correctly?
-
There is some bug in my code.
2
Answers
In the current Docker version, there is a default limitation on the Docker container storage of 10 GB.
You can check the disk space that containers are using by running the following command:
It’s also possible that the file your container is trying to access has access level restrictions. Try to make it available for docker or maybe everybody (chmod 777 file.txt).
This is likely a bug in your code. Most programs print the error they encounter, and when a program encounters out-of-space, the error returned by the filesystem is: "No space left on device" (errno 28
ENOSPC
).If you see FileNotFoundError, that means the file is missing. My best theory is that it’s coming from your consumer process.
It’s still possible though, that the file doesn’t exist because the producer ran out of space and you didn’t handle the error correctly – you’ll need to check your logs.
It might also be a race condition, depending on your application. There’s really not enough details to answer that.
As to the title question:
By default, docker just overlay-mounts an empty directory from the host’s filesystem into the container, so the amount of free space on the container is the same as the amount on the host.
If you’re using volumes, that depends on the storage driver you use. As @Dan Serbyn mentioned, the default limit for the devicemapper driver is 10 GB. The overlay2 driver – the default driver – doesn’t have that limitation.