By default docker will put all the data including images under /var/lib/docker(At least on Debian). This could let to problems with space. It's the case on my home server so i had to move docker location. I had to mount /var/lib/docker to new place. Because my /var and /usr are mounted to different partitions and discs i try to solve space problem by mounting docker default location to new mount under /usr/local/docker transparently.
First backup of fstab
sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)
Then stop docker and copy all files per rsync preserving all attributes.
sudo service docker stop
sudo mkdir /usr/local/docker
sudo rsync -aXS /var/lib/docker/. /usr/local/docker/
Now it was important to check that everything was copied right. I've did eye check, but diff -r
command is useful to. Ok it's important to make new mount and make it durable in fstab. That is what was useful in my case inside of fstab.
# <file> <system> <mount point> <type> <options> <dump> <pass>
# ...
/usr/local/docker /var/lib/docker none bind 0 0
Now mount of new configuration without reboot.
mount -a
And your docker has enough space again!
#参考#
http://alexander.holbreich.org/moving-docker-images-different-partition/