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:

  • How Docker calculates the hash of each layer? Is it deterministic?
  • AWS Elastic Beanstalk container_commands in Python 3.4 Docker Container
  • Saving function output into a variable named in an argument
  • Access service on subdomain in Kubernetes
  • How to open port for docker container?
  • Docker, Kafka - replication doesn't work between remote brokers
        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?

  • Developer environment - how to call/consume other micro services
  • delete volumes from images
  • Google cloud sdks doesn't start preview for Docker image Mac OS
  • Docker on Ubuntu 15.10 32 bit (OS and Processor)
  • Docker Swarm - get services by secret
  • Nvidia-docker - cant find on building process
  • 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.