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
网友评论