move-docker-root
Moving a docker root is not hard, but comes with 1 or 2 gotchas. In my case, I wanted to attach a disk to the docker root placed in /srv/docker, so I had to move the data out of the way, mount the disk, and than move it back.
Gotchas:
- Just running systemctl stop docker won’t actually stop docker
- File permissions for overlay2 is VERY important (you will run into permission denied on /tmp or similar)
- Finding the right commands :)
How To:
# Getting Docker to shut up
systemctl disable --now docker.socket
systemctl disable --now docker.service
# Getting the data out of the way
mv /srv/docker /root/docker
# Now do what you must
# if need be, stop it again and rm -rf /srv/docker/*
# Lets get the data back
cp -R -a /root/docker/* /srv/docker/
# Start docker and check that all is good
systemctl enable --now docker.service
systemctl enable --now docker.socket
# Now the fun part, somehow overlay2 sometimes mounts the folder from your moved files. fun right? just umount those
umount /root/docker/overlay2/*/merged
# If so, cleanup after yourself
rm -rf /root/docker