Docker修改默认数据存放位置
Docker修改默认数据存放位置方法一# 查看Docker目前存储位置[root@docker ~]# docker info | grep -i dirDocker Root Dir: /var/lib/docker# 关闭Docker[root@docker ~]# systemctl stop dockerWarning: Stopping docker.service, but it ca
·
Docker修改默认数据存放位置
方法一
# 查看Docker目前存储位置
[root@docker ~]# docker info | grep -i dir
Docker Root Dir: /var/lib/docker
# 关闭Docker
[root@docker ~]# systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
# 迁移原有数据
[root@docker ~]# mkdir /data/docker
[root@docker ~]# mv /var/lib/docker/* /data/docker/
# 修改docker的systemctl管理文件,使用--graph指定存储位置
[root@docker ~]# cat /usr/lib/systemd/system/docker.service
............................
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph /data/docker
............................
[root@docker ~]# systemctl daemon-reload
[root@docker ~]# systemctl start docker
[root@docker ~]# docker info | grep -i dir
Docker Root Dir: /data/docker
方法二
# 查看Docker目前存储位置
[root@docker ~]# docker info | grep -i dir
Docker Root Dir: /var/lib/docker
# 关闭Docker
[root@docker ~]# systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by:
docker.socket
# 迁移原有数据
[root@docker ~]# mkdir /data/docker
[root@docker ~]# mv /var/lib/docker/* /data/docker/
# 修改配置文件,graph指定docker默认数据存放位置
[root@docker ~]# cat /etc/docker/daemon.json
{
"graph": "/data/docker"
}
# 启动docker
[root@docker ~]# systemctl start docker
[root@docker ~]# docker info | grep -i dir
Docker Root Dir: /data/docker
更多推荐
已为社区贡献3条内容
所有评论(0)