In a running Ubuntu system, I can successfully change Docker's default data location from /var/snap/docker/common/var-lib/docker
to /dockerdata
through the use of either daemon.json or the service. However, this only changes if I stop and start the service after booting the system. On a regular boot, the service starts with the snap location.
Stop Docker
sudo systemctl stop docker
Edit /etc/docker/daemon.json
{
"data-root": "/dockerdata"
}
alternately, edit /lib/systemd/system/docker.service (not both!)
...
ExecStart=/usr/bin/dockerd --data-root /dockerdata -H fd:// --containerd=/run/containerd/containerd.sock
...
then run
sudo systemctl daemon-reload
sudo systemctl start docker
This works until you reboot the system. When it comes back up, Docker is running with the original Root Dir. Restarting Docker as above then changes the Root Dir in accordance with the desired settings. The output of docker version
and docker info
are below.
Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:45:44 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a66213fe
Built: Mon Jun 22 15:44:15 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Client:
Debug Mode: false
Server:
Containers: 2
Running: 1
Paused: 0
Stopped: 1
Images: 2
Server Version: 19.03.12
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-40-generic
Operating System: Ubuntu 20.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.27GiB
Name: dockerhost
ID: NFF6:PGBA:AD2O:GEET:MYS5:NF23:SW5F:7T6E:XYFI:XNIH:7KRQ:B3NA
Docker Root Dir: /dockerdata
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false