How to move docker's default /var/lib/docker to another directory on Ubuntu/Debian Linux -

The following config will guide you through a process of changing the docker's default /var/lib/docker storage disk space to another directory. There are various reasons why you may want to change docker's default directory from which the most obvious could be that ran out of disk space. The following guide should work for both Ubuntu and Debian Linux or any other systemd system. Make sure to follow this guide in the exact order of execution.
This is a companion discussion topic for the original entry at



If you start docker and the images are gone and docker tries to fetch others, it’s because of rsync -aqxP /var/lib/docker/ /new/path/docker, normally it creates another docker container in the destination. The command should probably be rsync -aqxP /var/lib/docker/* /new/path/docker. Anyway, I fixed it without re-copying it using : cd /new/path/docker/docker;rm -rf ../{builder,containerd,containers,image,network,overlay2,plugins,runtimes,swarm,tmp,trust,volumes}; mv * ..



Didn’t work for me on OpenMediaVault3 running Debian 8
Docker seems to be ignoring all the changes I do :S


Soma Consulting

After I restart server, I don’t see any containers.
so I tried to run rsync -aqxP /var/lib/docker/ /new/path/docker
Then I got the container with previous data and lost all the new update data.
What should I do to get the update data?


Tommy Powell

use daemon.json instead as suggested by kn. I followed the OP directions and the docker.service file got reset after and update.


François-Xavier Michaud

Great, thank you !

You should write :

ps aux | grep -i [d]ocker

to avoid call twice grep



Altering system scripts is a bad practice when:

  • they’re under a package manager control (s.a. apt): problems on package upgrade
  • the same could be achieved in a less intrusive way, i.e. through a configuration file

In this case, the recommended solution is to create a custom override as per documentation:

https://docs.docker. com/v1.11/engine/reference/commandline/daemon/#daemon-configuration-file



Great, thanks!!!


Arnaud Marchand

Works perfectly. Docker version 17.03.0-ce, build 60ccb22
On ubuntu 16
Thanks for sharing.



Instead of modifying the systemd startup script, one can modify the “-g / --graph” option by adding a /etc/docker/daemon.json with the contents of:

“graph”: “/new/path/docker”

Other options can also be inserted into that file, e.g. TLS usage



Thanks, this worked for me on:

Kernel Version: 4.4.0-62-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64

I had some issues setting the docker root to a non-static mount drive. I used this to set a static mount which solved my problem: http://askubuntu .com/questions/299131/hard-drive-location-keeps-changing-after-upgrade-to-13-04


Martin Goldhahn

Thanks for sharing this one.


I would suggest using this rsync command:

 rsync -aqxHPX --delete /var/lib/docker/ /new/path/docker

-H to ensure hard links are not expanded to duplicate files.
-X for anyone using SELinux to preserve labels