美文网首页
docker 更改默认存储路径

docker 更改默认存储路径

作者: 勇不言弃92 | 来源:发表于2020-04-06 11:34 被阅读0次

docker默认存储位置为:‘/var/lib/docker’,准备改成‘/www/docker’

查看docker当前默认存储位置

//方法一:
docker info
//方法二:
sudo docker info | grep "Docker Root Dir"

停止docker

service docker stop

拷贝原docker相关镜像及容器等文件

cp -r /var/lib/docker/* /www/docker

修改docker配置文件

$ vim /usr/lib/systemd/system/docker.service
Redirecting to /bin/systemctl stop docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --data-root /www/docker
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID

只修改此行:

ExecStart=/usr/bin/dockerd   --data-root /www/docker

reload配置文件

systemctl daemon-reload

启动docker

service docker start

相关文章

网友评论

      本文标题:docker 更改默认存储路径

      本文链接:https://www.haomeiwen.com/subject/rrvvphtx.html