Dealing with Docker taking over your root volume in Linux

Andrei Dascalu
1 min readMay 2, 2018

By default docker stuffs itself in /var/lib/docker.

Everything goes there, temp files, volumes, images, etc. If you have a larger storage attached though, you may want to keep your root volume/partition clean and just use the other larger volume.

However, docker is slightly fussy about accessing its data so the course of action may not be obvious to everyone. So here it goes:

systemctl stop docker

rsync -aHSX /var/lib/docker /mnt/docker

mount --bind /mnt/docker /var/lib/docker

systemctl start docker

  1. Stop docker, obviously
  2. Rsync the existing folder to another folder (any folder on the other volume)
  3. Bind-mount the new folder over the existing docker folder (you may delete the contents of /var/lib/docker … or just back it up somewhere)
  4. Start docker
  5. Recommended: add a line into /etc/fstab to make your mount permanent.

--

--