2.7.2 Configuring Docker Storage Manually

This section discusses manually setting up a file system for Docker containers.

To manually prepare a dedicated file system to manage Docker containers:

  1. Configure the Docker Engine to use Btrfs as the storage driver to manage containers. Use yum to install the btrfs-progs package:

    # yum install btrfs-progs

    If the root file system is not configured as a Btrfs file system, create a Btrfs file system on a suitable device or partition such as /dev/sdb1 in this example:

    # mkfs.btrfs /dev/sdb1
  2. Configure the Docker Engine to use a block device formatted with XFS in conjunction with the overlay2 storage driver to manage containers. Format the block device with the XFS file system, for example to format a partition /dev/sdb1:

    # mkfs -t xfs -n ftype=1 /dev/sdb1

    It is essential that you use the -n ftype=1 option when you create the file system or you cannot use overlayfs. To check if a mounted XFS partition has been formatted correctly, run the following command and check the output to make sure that ftype=1:

    # xfs_info /dev/sdb1 | grep ftype
  3. Use the blkid command to display the UUID and TYPE for the new file system and make a note of this value, for example:

    # blkid /dev/sdb1
    /dev/sdb1: UUID="26fece06-e3e6-4cc9-bf54-3a353fdc5f82" TYPE="xfs" \

    The UUID for the file system on the device /dev/sdb1 in this example is the UUID value 26fece06-e3e6-4cc9-bf54-3a353fdc5f82. You can ignore the PARTUUID value, which is the UUID of the underlying partition. The TYPE of file system in this example is the TYPE value xfs.

  4. Create an entry in your /etc/fstab file to make sure the file system is mounted at boot. Open /etc/fstab in an editor and add a line similar to the following:

    UUID=UUID_value /var/lib/docker   fstype     defaults        0 0

    Replace UUID_value with the UUID value. Replace fstype with the file system TYPE.


    Previous versions of Docker required that dedicated storage used by Docker was mounted via a Systemd mount target and a Systemd drop-in file for the Docker service. This requirement was related to an issue where the storage was automatically unmounted when the Docker service was stopped. This issue no longer applies. If your storage is currently mounted using these methods, consider simplifying your environment by removing the Systemd drop-in and mount target and replacing this with an fstab entry.

    This entry defines a mount for the file system on /var/lib/docker. You might need to create this directory if you are performing a fresh installation:

    # mkdir /var/lib/docker

    You must mount the file system to start using it:

    # mount /var/lib/docker