Preparing a CentOS or RHEL 7 system for running containers

Docker Container Deployment

Step 1: read general requirements checklist

Step 2: install and patch operating system

Step 3: disable incompatible services

Step 4: verify general system requirements

Step 5: configure firewall settings

Each host must allow incoming connections on the following ports

Step 6: create docker storage

On CentOS/RHEL 7, Docker uses the "devicemapper" storage driver by default to manage container images and disk layers. For production, the storage driver must be configured to use "direct-lvm" mode (The "loop-lvm" mode is acceptable for testing, but is not supported). The "direct-lvm" mode requires one free block device (a disk or a partition).

WARNING: This procedure will delete all existing Docker images and containers.

If a free block device is available, go to Step 1B.

1A. Create a block device

You can attach a new disk, or create a new partition. The block device should be at least 40 GB in size. Attaching a new disk is outside the scope of these instructions. To create a new partition, use fdisk. Set the partition type to 8e (Linux LVM). See for detailed information on fdisk.

1B. Note the path of the block device, e.g., /dev/sdb for a disk, /dev/sdc1 for a partition.

2. Create an LVM thin pool

Ensure that LVM is installed on the host:

yum list lvm2

The "lvm2" package should be listed as installed. If it is not, then install it:

yum install lvm2

Invoke the following bash script with the block name noted in Step 1B: BLOCK_DEVICE_NAME "docker-vg"

#!/usr/bin/env bash
function create_thinpool_from_block_device()
local block_dev="$1"
local vg_name="$2"
# Create physical volume
pvcreate "$block_dev"
# Create volume group
vgcreate "$vg_name" "$block_dev"
# Create logical volumes (one for data, another for metadata)
lvcreate --wipesignatures y -n thinpool "$vg_name" -l 95%VG
lvcreate --wipesignatures y -n thinpoolmeta "$vg_name" -l 1%VG
# Convert data volume to a thin volume, using metadata volume for thin volume metadata
lvconvert -y --zero n -c 512K --thinpool "$vg_name/thinpool" --poolmetadata "$vg_name/thinpoolmeta"
# Ensure both volumes are extended as necessary
# 1. Create a profile
cat > "/etc/lvm/profile/$vg_name-thinpool.profile" <<EOF
activation {
# 2. Link profile to data volume
lvchange --metadataprofile "$vg_name-thinpool" "$vg_name/thinpool"
# 3. Enable monitoring of data volume size, so that extension is triggered automatically
lvs -o+seg_monitor
function usage()
cat >&amp;2 <<EOF
Creates an lvm thin pool in the VOL_GRP_NAME volume group (e.g. docker-vg)
using the BLOCK_DEV block device (e.g. /dev/xvdb).
NOTE: There is a set of rules that determine valid volume group names. This
script does not validate the name. See the lvm manpage for details.
if [ "$#" -ne 2 ]; then
exit 1
echo create_thinpool_from_block_device "$1" "$2"

May 06, 2016