Configuring Docker Storage

Docker by default uses a loopback file for container and image storage. This configuration provides less than optimal performance. The recommended method is to use a separate disk for hosting the docker images, containers, and metadata. This post will cover configuring a Docker host to utilize a secondary disk for docker storage.

This should only be done on a new installation or if data has been moved as this operation will wipe out all containers and images from the system.

Stop docker
systemctl stop docker
Find the additional drive
fdisk -l
Create lvm physical volume

The additional disk from the previous step should be used.

pvcreate /dev/sdb
Create volume group
vgcreate group_name /dev/sdb
Create data logical volume
lvcreate --wipesignatures y -n data group_name -l 95%VG
Create data logical volume
lvcreate --wipesignatures y -n metadata group_name -l 5%VG
Update Docker system file

Update the /etc/sysconfig/docker with the following entries as OPTIONS.

  • –storage-opt dm.datadev=/dev/group_name/docker-dm-data
  • –storage-opt dm.metadatadev=/dev/group_name/docker-dm-meta
  • –storage-opt dm.basesize=40G
Cleanup docker
rm -rf /var/lib/docker
Reload systemctl daemon to use the updated service file
systemctl daemon-reload
Start Docker
systemctl start docker
Verify changes
docker info 

References:
http://developerblog.redhat.com/2014/09/30/overview-storage-scalability-docker/