I. Introduction
After installation Centos7 docker, and a container for storing default image path / var / lib / Docker , can use the command docker info view.
However, this route is used by default disk storage system, if the mounted disk data, the need to modify the default storage path docker to mount the disk directory data, the need to modify the configuration of the docker.
Second, step
Change setting
Will be --graph /data/docker
added to the docker.service
file ExecStart
behind the field where /data/docker
you need to modify the storage directory
mkdir -p /data/docker vim /usr/lib/systemd/system/docker.service
will
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
change into:
ExecStart=/usr/bin/dockerd --graph /data/docker -H fd:// --containerd=/run/containerd/containerd.sock
Restart Service
systemctl daemon-reload
systemctl restart docker
Then perform docker info
when to see the catalog has been modified:
# docker info|grep 'Docker Root Dir' Docker Root Dir: /data/docker
Third, the test
Download a redis image
docker pull redis
View sha256
# docker inspect -f {{".Id"}} redis sha256:c33c9b2541a8fea04fe621e1e9d4e5973d9062f2a4eaac7a8d8b82c23c1b0aa8
View storage directory
# ls -l /data/docker/image/overlay2/imagedb/content/sha256/ 总用量 8 -rw------- 1 root root 6648 12月 31 17:25 c33c9b2541a8fea04fe621e1e9d4e5973d9062f2a4eaac7a8d8b82c23c1b0aa8
This article reference links: