15

Docker folder /var/lib/docker/aufs/diff grows too much and I would like to move it on an other partition. Is there a way to configure Docker to use another location for this foder?

Usman Ismail
  • 17,999
  • 14
  • 83
  • 165
guillaume
  • 6,477
  • 5
  • 17
  • 15

2 Answers2

19

There's an easy way to get the docker daemon to handle this for you.

stop docker

$ service docker stop

add this line to /etc/default/docker

# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="-g /<new destination>/docker/"

start docker

$ service docker start

verify the docker files and folders are created in the new destination

remove /var/lib/docker

/var/lib$ sudo rm -rf docker
Paul S
  • 1,424
  • 1
  • 14
  • 12
  • 1
    This is great. Where did you find this information? I searched for a little while, but could not find any comprehensive documentation for docker_opts – Marconius Aug 20 '15 at 03:28
  • This moves the whole `docker` directory to a different path - is there a way of migrating **only** one of its subdirectories (`aufs` in this case)? – Javier Arias May 09 '19 at 13:26
  • 1
    This does not work on Systemd, in other words, won't work in recent (>~15.04?) ubuntu or other distros. There's a warning on the file /etc/default/docker "# THIS FILE DOES NOT APPLY TO SYSTEMD" – wranvaud Jul 16 '19 at 20:54
3

There is an answer on this thread, basically a ln -s, after some preparatory work

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

https://github.com/docker/docker/issues/3127#issuecomment-30095645

Andy
  • 17,423
  • 9
  • 52
  • 69
user2915097
  • 30,758
  • 6
  • 57
  • 59