Change docker data directory

There are other ways to do this, but a simple one is to replace the default directory with a symbolic link to wherever you want to have your data directory. This is tested with OpenSuse LEAP 42.3.

Stop docker (if it is running):

service docker stop

Move the contents of the docker default data directory (under Suse this is /var/lib/docker/) to somewhere else:

mv /var/lib/docker/ /path/to/new/folder/

Now create a symbolic link to the new location in place of the default directory:

ln -s /path/to/new/folder/ /var/lib/docker/

Start docker again, it should use the new location:

service docker stop

(PS: In my case I had not deleted all containers and images before, so I had some things that linux didn’t want to move to the new location. I just deleted them manually:)

btrfs subvolume delete btrfs/subvolumes/*
This entry was posted in Virtualization and tagged , by swk. Bookmark the permalink.

About swk

I am a computational linguist, teacher of computer science and above all a huge fan of LaTeX. I use LaTeX for everything, including things you never wanted to do with LaTeX. My latest love is lilypond, aka LaTeX for music. I'll post at irregular intervals about cool stuff, stupid hacks and annoying settings I want to remember for the future.