Docker Community Forums

Share and learn in the Docker community.

How do I change the Docker image installation directory?

(Amos Folarin) #21

Those on 16.04 see comment by @thaJeztah

It’s also possible to use a daemon.json configuration file instead of /etc/default/docker. The /etc/default/docker is only used for systems running upstart, and not for systems running systemd, so is more portable. Also it allows reloading some configuration settings without restarting the daemon;


I’m on Ubuntu 16.04.1, but it shouldn’t matter because this is a cross-distro solution.

Just put this json into /etc/docker/daemon.json:

“graph”: “/path/to/docker”
Worked for me and I didn’t have to mess with upstart or systemd.

(Prakashriti) #23

I want to do this centos7, could anyone please suggest me how to achieve this? I am using centos 7 and latest docker version 1.13. I have mounted a storage drive /dev/sdb and i want the docker to use this drive instead of /var/lib/docker.

(Diegofcornejo) #24

Thanks, that’s worked for me, on Fedora 25 :slight_smile:

(Samir B. Amin) #25


Works for docker raspberry pi 3, debian jessie running docker version 17.03.0-ce

(Yuriarthem) #26

Thank you so much! That’s worked perfectly!!!


(H04x) #27


Modifying the docker.service.d might be a problem when updating the packages.
for Centos, you should modify:
OPTIONS=’–selinux-enabled --log-driver=journald --signature-verification=false -g /new/path/to/docker


(Diegomelo182) #28

That works, thanks!!!

(Darkzealot) #29

For anyone browsing this page in the future looking for a shell script to move/change the docker root directory on Ubuntu (tested with 16.04), you can download it directly or visit my site

#change paths below to suit your needs

set -e
dockerdir_new2=$(echo "$dockerdir_new" | sed 's/\//\\\//g')
systemctl stop docker
mkdir -p $dockerdir_new
rsync -a $dockerdir_old* $dockerdir_new
sed -i.bak "/ExecStart=\/usr\/bin\/dockerd \-H fd:\/\//c ExecStart=\/usr\/bin\/dockerd \-H fd:\/\/ -g ${dockerdir_new2}" /lib/systemd/system/docker.service
mv $dockerdir_old /var/lib/docker.bak/
ln -s $dockerdir_new /var/lib/docker
systemctl daemon-reload
systemctl start docker.service
printf '\n* The Docker systemd config has been backed up to /lib/systemd/system/docker.service.bak\n* A backup of the old Docker Root has been copied to /var/lib/docker.bak/\n\n'
docker info | grep 'Root Dir'

(Clipartpig) #30

I tried. Worked !!! Thanks :slight_smile:

(Darkzealot) #31

You’re welcome. Took me all day dealing with sed’s delimiter escapes. I’m sure there is a more proficient scripter out there who may want to improve on my script, but hey, it works great.

(Instasafari) #32

Worked perfectly thanks !!! :smiley:

(Vladox) #33

For newer versions you would need to have a look here:

Here is the content of “etc/docker/daemon.json”

  "graph": "/mnt/docker"

(bk) #34

Mine is rhel . The solution worked for me.
I restarted my aws instance then I face the below error when I start docker service.

Job for docker.service failed because the control process exited with error code. See “systemctl status docker.service” and “journalctl -xe” for details.

Have created a separate topic. appreciate your help .

(Toshiueno) #35

I’ve used “data-root” instead, I think because the docker version… tks!

(Hsiming) #36

Thanks! This works perfectly on ubuntu 16.04.3.

(Alberto Rojas) #37

Has someone find this error after moving the Docker folder?

[root@dgdalecfg201 docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get x509: certificate signed by unknown authority.
See 'docker run --help'.

The problem was that the admin from this servers changed the domain or something like that, what I did to fix this was run this command: sudo update-ca-trust This was the fix on CentOS.

(Astein58) #38

Great, but now it looks like it is better to use “data-root”.
The docker daemon tolled me:

WARN[0000] The “graph” config file option is deprecated. Please use “data-root” instead.

Thanks, it’s poorly documented.