How do I change the Docker image installation directory?

I could not rsync or mv or cp /var/lib/docker to /opt. Yes, I had docker daemon turned off and chkconfig docker off before reboot etc. These attempts to move the data never finished running.

Thankfully I did not have any images or containers to move so I was able to change the default dir in /etc/sysconfig/docker and voila, all the docker “run files” were created in /opt/docker. I didn’t even need to create /opt/docker, the init did that for me.

So bottom line is, if you have no images you need to preserve, just add the path to /etc/sysconfig/docker (rhel) or /etc/defaults/docker (debian) and you’re done. You can then nuke /var/lib/docker.