Centos 7: 改变docker的image存放目录
Posted eikixu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos 7: 改变docker的image存放目录相关的知识,希望对你有一定的参考价值。
steps:
1. mkdir /data/docker 创建新的存放目录
2. systemctl stop docker 关闭docker进程
3. vi /usr/lib/systemd/system/docker.service
添加 -g /home/docker
[[email protected] data]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target rhel-push-plugin.socket registries.service
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/run/containers/registries.conf
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 /data/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
--init-path=/usr/libexec/docker/docker-init-current
--seccomp-profile=/etc/docker/seccomp.json
$OPTIONS
$DOCKER_STORAGE_OPTIONS
$DOCKER_NETWORK_OPTIONS
$ADD_REGISTRY
$BLOCK_REGISTRY
$INSECURE_REGISTRY
$REGISTRIES
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
KillMode=process
[Install]
WantedBy=multi-user.target
4. cp -R /var/lib/docker/* /data/docker/ 复制之前的镜像数据到新的目录
5. systemctl daemon-reload 重新加载配置信息
6. systemctl start docker 重新启动docker进程
以上是关于Centos 7: 改变docker的image存放目录的主要内容,如果未能解决你的问题,请参考以下文章