How to change docker installation directory in centos 7 with docker 1.13 version How to change docker installation directory in centos 7 with docker 1.13 version docker docker

How to change docker installation directory in centos 7 with docker 1.13 version


According to the Docker Document, the recommended way is to use the platform-independent daemon.json file, which is located in /etc/docker/ on Linux by default.

Set the following flags in the daemon.json file:

{  "data-root": "/mnt/docker-data",  "storage-driver": "overlay"}


Centos 7 uses systemd, so you can create an override file in /etc/systemd/system/docker.service.d/override.conf that specifies alternate command flags to pass to dockerd when starting in order to use a directory other than /var/lib/docker for your container storage:

[Service]ExecStart=ExecStart=/usr/bin/dockerd --graph=/mnt/docker-data --storage-driver=overlay

Another option would be to mount the disk you have mounted at /mnt at /var/lib/docker directly.

Further details are in the official docs.


For Centos 7, you should modify file: /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runsOPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --graph=/new/path/to/docker --iptables=False --storage-driver=overlay'

I have also disabled iptables, you can remove it.

Modifying the /usr/lib/systemd/system/docker.service might be a problem when updating the packages.