Increase disk size of docker containers when using device mapper

Hi. If you you are using docker with device mapper (for instance, the default config on a fedora system) you might want to change 2 things:

* Increase the storage disk for one container which defaults to 10G
* Increase the total data space used by docker on your platform, which defaults to (type ‘docker info’): Data Space Total: 107.4 GB

Important notice: If you perform the following operations, you will lose all images and containers.

Before performing these operations, stop the docker service.

docker service stop

Increase the data storage used by a container

Edit the docker config file, usually /etc/sysconfig/docker. Modify the options line and add –storage-opt dm.basesize=400G. For me, it looks like this:

-g /DATA/docker --storage-opt dm.basesize=90G --storage-driver=devicemapper 

The -g option specify the docker hoe folder. Device mapper will create files in this folder.
I set the max disk size of a container to 90G. Of course this is a boundary, my containers will not take as much, but they are bounded to that.

Increase the total data storage used by your docker installation
I took the solution from this post.
My docker home folder is in /DATA/docker. If you use the default config, replace /DATA/docker with /var/lib/docker in the following operations.

* Remove the docker folder

  rm -rf /DATA/docker

* Create the storage folder

mkdir -p /DATA/docker/devicemapper/devicemapper

* Create your pool. Let’s create a 250G file

dd if=/dev/zero of=/DATA/docker/devicemapper/devicemapper/data bs=1G count=0 seek=250 

This is it. You can now start docker service:

docker service start

Type docker info to see the ‘Data Space Total’ property value.
Download your images and start your containers. Inside a container type ‘df -h’. You should now see 90G of disk storage.

Advertisements
This entry was posted in docker, linux. Bookmark the permalink.

One Response to Increase disk size of docker containers when using device mapper

  1. Pingback: Recover a docker container which ran out of space with device mapper | esalagea

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s