Valentin Golev
Valentin Golev

Reputation: 10095

how to increase docker build's volume size

One of my steps in Dockerfile requires more than 10G space on disk. It really does. However, all the intermediate containers in docker build are created with 10G volumes.

What I did:

It's no good: df -h in an intermediate container still shows a 10G disk, and docker inspect of it shows "DeviceSize": "10737418240".

What have I missed? How do I increase the base volume size?

Upvotes: 10

Views: 14397

Answers (2)

JSON C11
JSON C11

Reputation: 11802

To grant containers access to more space, we need to take care of two things:

  1. Make sure that dockerd is started with: --storage-opt dm.basesize=25G
  2. Make sure that we pull a clean version of the image after increasing the basesize.

Example:

  1. Start dockerd with:
    --storage-opt dm.basesize=25G
    
  2. Restart docker daemon
  3. Checking the container size here will display the older value of 10G:
    docker run -it --rm ubuntu:xenial df -h
    
  4. Delete the image and repull it
    docker rmi ubuntu:xenial
    docker pull ubuntu:xenial
    
  5. Confirm changes took place with the expected value of 25G:
    docker run -it --rm ubuntu:xenial df -h
    

Upvotes: 3

linux-fan
linux-fan

Reputation: 373

I am not sure if this problem has been resolved in the meantime or not. But if anyone stumbles across this in 2019 (or possibly later), the clean solution to this kind of problems is to switch to another storage backend.

To do this, copy all keepworthy Docker data to a safe location. Stop the Docker daemon. Delete /var/lib/docker (or move it away to allow a rollback if anything goes wrong). Then re-create an empty /var/lib/docker and add file daemon.json with the following content

{
  "storage-driver": "overlay2"
}

Then, restart the Docker daemon and the artificial 10G limit is gone.

See the documentation for further details: https://docs.docker.com/storage/storagedriver/overlayfs-driver/

In case there is really no way around the DeviceSize thing, I remember once creating it by hand (in the sense of a dd command with the expected device size) and starting the Docker daemon afterwards. However, as of today, necessity for doing this should be gone.

Upvotes: 2

Related Questions