Prepare your new block storage, this will house the moved docker folder
# format the new block storage device
mkfs.ext4 /dev/sdx
# create a mount point
mkdir /mnt/diskX
# mount the file or do equivalent mount in /etc/fstab
mount /dev/sdx1 /mnt/diskX
# create a new folder to house docker
mkdir /mnt/diskX/docker
chmod 700 /mnt/diskX/docker
Setup the move
# stop containers and docker daemon
docker ps -q | xargs docker kill
service docker stop
# if devicemapper exists
cd /var/lib/docker/devicemapper/mnt
umount ./*
# mv didn't work with sudo, must be ROOT user -
sudo bash
mv /var/lib/docker /mnt/diskX/docker
# set the flag in /etc/default/docker to
e.g. DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /mnt/diskX/docker"
# restart docker daemon
sudo /etc/init.d/docker restart
Test that when you create a container the hash appears in /mnt/diskX/docker/containers
- Source google forum