Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to increase docker build's volume size

Tags:

docker

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:

  • started dockerd with --storage-opt dm.basesize=25G (docker info says: Base Device Size: 26.84 GB)
  • disabled cache while building
  • re-pulled the base images
  • stopped docker, removed everything from the docker directory, and started it again

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?

like image 630
Valentin Golev Avatar asked Aug 26 '16 06:08

Valentin Golev


People also ask

Can I add volume to existing docker container?

Adding a Volume To a Running Docker Container Containers must have their volumes configured on startup, which means to add a new volume, you must restart the container. While there is a hacky solution (more on that below), it's highly recommended that a container restart should be done anyway.

How do I increase my dev SHM in docker?

You can modify shm size by passing the optional parameter --shm-size to docker run command. The default is 64MB.

What is the default size of a docker volume?

By default, volumes are 20GB and can be changed with --storage-opt "size=50GB" . Note that this method works for docker build.


1 Answers

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
    
like image 78
JSON C11 Avatar answered Nov 16 '22 02:11

JSON C11