Dealing with Docker taking over your root volume in Linux
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
- Stop docker, obviously
- Rsync the existing folder to another folder (any folder on the other volume)
- 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)
- Start docker
- Recommended: add a line into /etc/fstab to make your mount permanent.