Best way to move docker directory #3127

url:https://github.com/docker/docker/issues/3127
 
Soulou commented on 9 Dec 2013

Ok it's done, and it worked quite well:

docker ps -q | xargs docker kill
stop docker
cd /var/lib/docker/devicemapper/mnt
umount ./*
mv /var/lib/docker $dest
ln -s $dest /var/lib/docker
start docker

And Is seems to be working !

 
@SoulouSoulou closed this on 9 Dec 2013
 
@thomasleveil

ln -s $dest /var/lib/docker

This was the cause of issues with the docker rm command (error about being Unable to remove filesystem)
The solution to avoid having a symbolic link is to start docker with the -g parameter

On Ubuntu that option is to be set in the /etc/default/docker file

DOCKER_OPTS="-g /somewhere/else/docker/"
 
@tianon
Docker member

and if you want to get really fancy, you can use something like:

DOCKER_OPTS="-g $(readlink -f /var/lib/docker)"

原文地址:https://www.cnblogs.com/ycliu912/p/5465781.html