1.docker默认存储位置为/var/lib/docker
sudo docker info | grep "Docker Root Dir" #查看默认存储位置
WARNING: No swap limit support
Docker Root Dir: /var/lib/docker
df /var/lib/docker # 查看文件夹挂在位置
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 41151808 16235916 22802464 42% /var/lib/docker
2.停止docker进程
systemctl stop docker
3.拷贝或移动docker文件至新目录
mv -R /var/lib/docker/* /opt/docker/
4.修改配置文件daemon.json
vim /etc/docker/daemon.json
{
"insecure-registries":["47.98.121.87:8088"],
"registry-mirrors":["http://hub-mirror.c.163.com"],
"graph": "/opt/docker"
}
增加一行代码"graph": "/opt/docker"
5.重新加载docker配置文件,启动docker即可
systemctl daemon-reload
systemctl restart docker
网友评论