After Centos7 installs docker, the default image and container storage path is /var/lib/docker, you can use the command docker info to view.
However, this path uses the storage of the system disk by default. If the data disk is mounted, you need to modify the default storage path of docker to the mount directory of the data disk, and you need to modify the relevant configuration of docker.
Add --graph /data/docker
after the ExecStart
field in the docker.service
file, where /data/docker
is the storage directory you need to modify
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
systemctl daemon-reload
systemctl restart docker
When you execute docker info
again, you can see that the directory has been modified:
# docker info|grep 'Docker Root Dir'
Docker Root Dir:/data/docker
Download a redis image
docker pull redis
View sha256
# docker inspect -f {{".Id"}} redissha256:c33c9b2541a8fea04fe621e1e9d4e5973d9062f2a4eaac7a8d8b82c23c1b0aa8
View storage directory
# ls -l /data/docker/image/overlay2/imagedb/content/sha256/
Total amount 8-rw-------1 root root 664812 3117:25 c33c9b2541a8fea04fe621e1e9d4e5973d9062f2a4eaac7a8d8b82c23c1b0aa8
Reference link for this article:
https://blog.csdn.net/bacteriumX/article/details/88417098
https://www.jianshu.com/p/8cd83436373b
Recommended Posts