5
docker 数据目录迁移教程
source link: https://hellodk.cn/post/633
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
docker 数据目录迁移教程
# docker info |grep 'Docker Root Dir'
Docker Root Dir: /opt/docker
- openwrt 默认的 Docker Root Dir 是 /opt/docker
- armbian 默认的是 /var/lib/docker ,和大部分 Linux 发行版一样
- 先停止docker服务
- openwrt:
/etc/init.d/dockerd stop
- armbian:
systemctl stop docker
(root权限下执行)
- openwrt:
-
再拷贝文件,通过
rsync -av source-path destination-path
rsync 使用 -av 两个参数选项
比如rsync -av /var/lib/docker/ /mnt/ssd/dockerdata
- 然后再更改
/etc/docker/daemon.json
中的 data-root 字段,改成新的路径。ps: 如果这个json文件中没有这个字段,创建即可 - 看情况把 docker容器持久化了的 配置文件 volumes的映射关系的路径也转移一下
- 重新启动 docker daemon (init.d 下的 dockerd 或者 systemd 管理的 docker.service)
- 再执行
docker info
查看Docker Root Dir
的值,看是否生效
关于第二点,因为 rsync 比 cp、mv 更安全 所以建议使用 rsync
附上一个我正在使用的 /etc/docker/daemon.json
"data-root": "/mnt/ssd/dockerdata",
"log-level": "warn",
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com",
"https://registry.docker-cn.com"
"dns": ["223.5.5.5","180.76.76.76","114.114.114.114","8.8.8.8","10.10.10.1"],
"bip": "192.168.20.1/23"
标签: docker
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK