docker修改默认存储路径
docker修改默认存储路径一、环境:centos7.x系统,已经装好docker-ce服务包二、查看当前docker的存储路径[yukw@yfb ~]$ docker info |grep DirWARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabledWARNI...
·
docker修改默认存储路径
第一种方式:
一、环境:
centos7.x系统,已经装好docker-ce服务包
二、查看当前docker的存储路径
[yukw@yfb ~]$ docker info |grep Dir
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release.
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Docker Root Dir: /var/lib/docker ## docker默认的存储路径
三、关闭docker服务
[yukw@yfb ~]$ sudo -s ## 切换到root用户
[sudo] password for yukw:
[root@yfb yukw]# systemctl stop docker ## 关闭docker服务
[root@yfb yukw]# systemctl status docker ## 查看docker服务状态
四、将原有数据迁移至新目录(这是在docker服务启动后需要做的操作,因为启动后docker默认会将数据存储在 /var/lib/docker/目录下)
[root@yfb yukw]# mkdir /data/service/docker -p
[root@yfb yukw]# mv /var/lib/docker/* /data/service/docker/
五、修改docker.service配置文件,使用 --graph 参数指定存储位置
[root@yfb yukw]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph /data/service/docker
六、重新加载配置文件
[root@yfb yukw]# systemctl daemon-reload
七、启动docker服务
[root@yfb yukw]# systemctl start docker
[root@yfb yukw]# systemctl enable docker
[root@yfb yukw]# systemctl status docker
八、查看修改是否成功
[yukw@yfb ~]$ docker info | grep Dir
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release.
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use.
Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Docker Root Dir: /data/service/docker ## 查看修改成功
第二种方式:
# mkdir /etc/docker/
# vim /etc/docker/daemon.json
好了,这就是修改docker默认存储路径的方法,如有问题可与博主交流讨论!
更多推荐
已为社区贡献2条内容
所有评论(0)