Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize disk usage of a Docker container

Every Docker container will be configured with 10 GB disk space, which is the default configuration of devicemapper in CentOS. So how can I configure every container newly created with more than 10 GB disk space in default? (The host server is installed with CentOS 6 and Docker 1.7.1)

like image 587
Xingjun Wang Avatar asked May 08 '16 12:05

Xingjun Wang


2 Answers

  1. (optional) If you have already downloaded any image via docker pull you need to clean them first - otherwise they won't be resized

    docker rmi your_image_name

  2. Edit the storage config

    vi /etc/sysconfig/docker-storage

    There should be something like DOCKER_STORAGE_OPTIONS="...", change it to DOCKER_STORAGE_OPTIONS="... --storage-opt dm.basesize=100G"

  3. Restart the docker deamon

    service docker restart

  4. Pull the image

    docker pull your_image_name

  5. (optional) verification

    docker run -i -t your_image_name /bin/bash

    df -h

I was struggling with this a lot until I found out this link http://www.projectatomic.io/blog/2016/03/daemon_option_basedevicesize/ turns out you have to remove/pull image after enlarging the basesize.

like image 166
Ondrej Svejdar Avatar answered Sep 28 '22 19:09

Ondrej Svejdar


Yes you can. Use the dm.basesize attribute when starting the Docker daemon. For example:

docker daemon --storage-opt dm.basesize=50G ...

More info can be found in the official docs.

like image 45
johnharris85 Avatar answered Sep 28 '22 18:09

johnharris85