linuxdockercentos7docker-engine

Docker engine failing to start after changing docker root directory


I just created a new partition on my Linux CentOs 7, and after that I changed my Docker Root Directory from /var/lib/docker to /data/docker.

In the 'docker.service' file I added the following config:

ExecStart=/usr/bin/dockerd -g /data/docker/ -H fd:// --containerd=/run/containerd/containerd.sock

, after that I copied data from /var/lib/docker to my new directory /data/docker and then I do

systemctl daemon-reload

and

systemctl start docker

BUT

The service didn't start and I got this message:

Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.

Process: 16925 ExecStart=/usr/bin/dockerd -g /data/docker/ -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE) Main PID: 16925 (code=exited, status=1/FAILURE)

Jun 29 23:26:37 linux.local systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE Jun 29 23:26:37 linux.local systemd[1]: Failed to start Docker Application Container Engine. Jun 29 23:26:37 linux.local systemd[1]: Unit docker.service entered failed state. Jun 29 23:26:37 linux.local systemd[1]: docker.service failed. Warning: docker.service changed on disk. Run 'systemctl daemon-reload'to reload units.

My Linux version:

Operating System: CentOS Linux 7 (Core) CPE Kernel: Linux 3.10.0-1160.90.1.el7.x86_64

Docker version:

Client: Docker Engine - Community Version: 24.0.2 API version: 1.43 Go version: go1.20.4 Git commit:
cb74dfc Built: Thu May 25 21:55:21 2023 OS/Arch:
linux/amd64 Context: default

Server: Docker Engine - Community Engine: Version: 24.0.2 API version: 1.43 (minimum version 1.12) Go version:
go1.20.4 Git commit: 659604f Built: Thu May 25 21:54:24 2023 OS/Arch: linux/amd64 Experimental:
false containerd: Version: 1.6.21 GitCommit:
3dce8eb055cbb6872793272b4f20ed16117344f8 runc: Version:
1.1.7 GitCommit: v1.1.7-0-g860f061 docker-init: Version: 0.19.0 GitCommit: de40ad0

Does anyone have any idea about what should I do?


Solution

  • I'm not sure if this is really caused by the docker version that I'm using, but the docker version that I'm using doesn't recognize the option -g, so the docker service doesn't know where the docker root directory is.

    After I checked the options known by 'dockerd', it turned out that the option that should be used was --data-root. After I replaced -g with --data-root, the docker.service could run using the new root directory.