Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change docker daemon root directory in CentOS7

I am running docker in CentOS7.

I'd like to change my basic directory from /var/lib/docker to /data/docker.

I found this guide from official site, but do not know how to apply this to my case.

I just make new daemon.json in /etc/docker/. After that when I am trying to run daemon occurs an error.

follow is systemctl status -l docker.service.

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2017-04-27 15:07:41 KST; 47s ago
     Docs: https://docs.docker.com
  Process: 42547 ExecStart=/usr/bin/dockerd (code=exited, status=1/FAILURE)
 Main PID: 42547 (code=exited, status=1/FAILURE)

Apr 27 15:07:41 DCSF-DEV08 systemd[1]: Starting Docker Application Container Engine...
Apr 27 15:07:41 DCSF-DEV08 dockerd[42547]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: default-ulimits
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: Failed to start Docker Application Container Engine.
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: Unit docker.service entered failed state.
Apr 27 15:07:41 DCSF-DEV08 systemd[1]: docker.service failed.

So how could I fix this?(And I would like to know what is default setting for daemon when I just run systemctl start docker without /etc/docker/daemon.json)

========= EDIT ===================

My current docker daemon.js.

{
    "api-cors-header": "",
    "authorization-plugins": [],
    "bip": "",
    "bridge": "",
    "cgroup-parent": "",
    "cluster-store": "",
    "cluster-store-opts": {},
    "cluster-advertise": "",
    "debug": true,
    "default-gateway": "",
    "default-gateway-v6": "",
    "default-runtime": "runc",
    "default-ulimits": {},
    "disable-legacy-registry": false,
    "dns": [],
    "dns-opts": [],
    "dns-search": [],
    "exec-opts": [],
    "exec-root": "",
    "fixed-cidr": "",
    "fixed-cidr-v6": "",
    "graph": "/data/docker",
    "group": "",
    "hosts": [],
    "icc": false,
    "insecure-registries": [],
    "ip": "0.0.0.0",
    "iptables": false,
    "ipv6": false,
    "ip-forward": false,
    "ip-masq": false,
    "labels": [],
    "live-restore": true,
    "log-driver": "",
    "log-level": "",
    "log-opts": {},
    "max-concurrent-downloads": 3,
    "max-concurrent-uploads": 5,
    "mtu": 0,
    "oom-score-adjust": -500,
    "pidfile": "",
    "raw-logs": false,
    "registry-mirrors": [],
    "runtimes": {
        "runc": {
            "path": "runc"
        },
        "custom": {
            "path": "/usr/local/bin/my-runc-replacement",
            "runtimeArgs": [
                "--debug"
            ]
        }
    },
    "selinux-enabled": false,
    "storage-driver": "",
    "storage-opts": [],
    "swarm-default-advertise-addr": "",
    "tls": true,
    "tlscacert": "",
    "tlscert": "",
    "tlskey": "",
    "tlsverify": true,
    "userland-proxy": false,
    "userns-remap": ""
}

The only thing I changed is graph, since I just want to change root directory. (I want to put others as default. default means same configuration as systemctl start docker)

like image 517
Juneyoung Oh Avatar asked Apr 27 '17 05:04

Juneyoung Oh


People also ask

How do I change docker daemon configuration?

To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon. json on Linux systems, or C:\ProgramData\docker\config\daemon. json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced.

What is docker root dir?

The docker root dir is the root path where all data docker is stored.


2 Answers

Edit /etc/docker/daemon.json.

Put only the following content:

{
    "data-root": "/data/docker"
}

Restart docker daemon: sudo service docker restart

For Json MetaData Refer: daemon.json from Docker documentation

like image 100
kstromeiraos Avatar answered Oct 12 '22 13:10

kstromeiraos


It is possible to change docker root directory by creating a systemd drop-in service file. This is useful when you want images and containers or docker generated files to be located in another partition or drive.

More information on this article :
https://medium.com/@wlarch/change-docker-root-directory-by-creating-a-systemd-drop-in-service-file-3c1244244784

like image 33
wlarcheveque Avatar answered Oct 12 '22 13:10

wlarcheveque