Docker container drive does not match available hard drive space on host

I have loaded a new custom image into a remote RedHat 7 docker host instance. When running a new container, the container does not attempt to use the entire disk. I get the following is the output of a df -h on the container:

    rootfs                9.8G  9.3G     0 100% /
                          9.8G  9.3G     0 100% /
    tmpfs                 1.9G     0  1.9G   0% /dev
    shm                    64M     0   64M   0% /dev/shm
                           49G   25G   25G  51% /etc/resolv.conf
                           49G   25G   25G  51% /etc/hostname
                           49G   25G   25G  51% /etc/hosts
    tmpfs                 1.9G     0  1.9G   0% /proc/kcore
    tmpfs                 1.9G     0  1.9G   0% /proc/timer_stats

But the host system has much more space:

  • Install Discourse (a docker image) on Openshift Online
  • How WSO2 APIM Gateway Worker gets published api artifacts when distributed setup get redeployed?
  • Tensorflow docker export weights
  • “tag latest not found” on docker pull with private registry
  • Microservices and database
  • call a docker container from another container
        Filesystem                   Size  Used Avail Use% Mounted on
        /dev/mapper/vg_root-lv_root   49G   25G   25G  51% /
        devtmpfs                     1.9G     0  1.9G   0% /dev
        tmpfs                        1.9G     0  1.9G   0% /dev/shm
        tmpfs                        1.9G  8.5M  1.9G   1% /run
        tmpfs                        1.9G     0  1.9G   0% /sys/fs/cgroup
        /dev/mapper/vg_root-lv_home  9.8G   73M  9.7G   1% /home
        /dev/sda1                    497M   96M  402M  20% /boot

    It seems as if docker is assigning the 9.8 gigs of the /home mapping to the entire drive of the container. So I am wondering if there is a reason I am seeing this?

  • can i create instances in Openstack using vagrant or docker?
  • Connecting to Meteor DDP from Java with Docker container
  • How to have docker restart container with a completely new container?
  • Can a docker image based on Ubuntu run in Redhat?
  • Can't install docker - Permission denied?
  • Simple Python Docker Script
  • One Solution collect form web for “Docker container drive does not match available hard drive space on host”

    The Problem

    I was able to resolve this problem. The issue was not related to the volume that was being mounted to the container (ie It was not mounting the home volume as the root volume on the container). The problem occurred because docker uses device-mapper in RedHat to manage the file systems of it’s containers. By default, the containers will start with 10G of space. In general, docker will use AUFS to manage the file systems of the containers. This is the case on most Debian based versions of Linux, but RedHat uses device-mapper instead.

    The Solution

    Luckily, the device-mapper size is configurable in docker. First, I had to stop my service, and remove all of my images/containers. (NOTE: There is no coming back from this, so backup all images as needed).

    sudo service stop docker && sudo rm -irf /var/lib/docker

    Then, start up the docker instance manually with the desired size parameters:

    sudo docker -d --storage-opt dm.basesize=[DESIRED_SIZE]

    In my case, I increased my container size to 13G:

    sudo docker -d --storage-opt dm.basesize=13G

    Then with docker still running, pull/reload the desired image, start a container, and the size should now match the desired size.

    Next, I set my docker systemd service file to startup with the desired container size. This is required so that the docker service will start the containers up with the desired size. I edited the OPTIONS variable in the /etc/sysconfig/docker file. It now looks like this:

    OPTIONS='--selinux-enabled --storage-opt dm.basesize=13G'

    Finally, restart the docker service:

    sudo service stop docker


    [1] – This is how I discovered RedHat uses device-mapper, and that device-mapper has a 10G limit.

    [2] – Found the storage options in dockers documentation.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.