docker默认镜像存储位置修改

一、问题描述

  docker默认安装后存储在/var/lib/docker目录下,如何修改docker镜像的默认存储路径,下面分享一下其过程

1.1 查看服务配置文件位置

systemctl show --property=FragmentPath docker

1.2 编辑文件内容

修改后的存储路径为/opt/docker

vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=all1.3 重新加载配置文件,重启docker服务
1.4 验证效果
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
-g /opt/docker \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave
[Install]
WantedBy=multi-user.target

 

1.3 重载docker服务

sudo systemctl daemon-reload
sudo systemctl restart docker

 

 

 

posted @ 2020-04-13 15:46  雪竹子  阅读(12848)  评论(0编辑  收藏  举报