In Docker 17, how is disk space allocated for containers?
There are various internet resources that suggest that, by default, docker containers are limited to 10g. However, those explanations go along with an indication that docker system info
will show the limit. I've got docker version 17.05.0-ce, and docker system info
shows no such limit, which suggests to me that the situation has changed. I've got a build that failed with 'out of space' on file system operations in the container. So, where is the space that I'm out of, and how do I allocate more of it? docker info
shows aufs
, so is the disk space sitting on the /var
file system?
Solution 1:
The "base size" limit you see defaulting to 10G is related to the devicemapper storage driver. It doesn't apply to aufs, overlay, overlay2, or other storage drivers. The devicemapper storage driver is commonly used on Red Hat installs.
With aufs, disk is used under /var/lib/docker, you can check for free space there with df -h /var/lib/docker
. If you mounted a volume into your container, that disk will be where ever your volume is mounted from. The named volumes default to /var/lib/docker, but other volumes, particularly host volumes, will be located in the directory you specify.
For more details, see:
Selecting a storage driver
Use the device mapper storage driver
Use the aufs storage driver
Solution 2:
I'll add for anyone looking for Windows information:
By default, volumes are 20GB and can be changed with --storage-opt "size=50GB"
.
Source: https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-storage
Image size
A common pattern for Windows applications is to query the amount of free disk space before installing or creating new files or as a trigger for cleaning up temporary files. With the goal of maximizing application compatibility the C: drive in a Windows container represents a virtual free size of 20GB. Some users may want to override this default and configure the free space to a smaller or larger value, this can be accomplished though the “size” option within the “storage-opt” configuration. Examples
Command line: docker run --storage-opt "size=50GB" microsoft/windowsservercore:1709 cmd
Docker Configuration File:
"storage-opts": [
"size=50GB"
]
Note that this method works for docker build. See the configure docker document for more details on modifying the docker configuration file.