Skip to content

Instantly share code, notes, and snippets.

@jthmiranda
Created August 10, 2015 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jthmiranda/3d8926265268c640e32e to your computer and use it in GitHub Desktop.
Save jthmiranda/3d8926265268c640e32e to your computer and use it in GitHub Desktop.
change docker directory to another partition
turns out you don't need the bind mount. This works with current docker by just modifying the -g option in /etc/docker/defaults DOCKER_OPTS. I had previously tried this and maybe like you failed to get it to work, and looked to linking and bind mounting.
Tried on AWS EC2 VM on a Ubuntu 14.04 server, with a second block storage volume.
First prepare your new block storage, this will house the moved docker folder
First format and mount the new block storage device
mkfs.ext4 /dev/sdx
Mount it
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 it exists
cd /var/lib/docker/devicemapper/mnt
umount ./*
move /var/lib/docker to the new mounted storage device
mv didn't work with sudo, must be ROOT user! e.g. sudo bash first
root@foo# 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/dock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment