Docker(DinD)映像中的Docker使用vfs存储驱动程序而不是overlay2

hivapdat  于 2023-01-20  发布在  Docker
关注(0)|答案(1)|浏览(236)

我在docker(DinD)中有一个带有debian-11靶心的docker图像。在我的host machine上运行命令docker info

# host machine
# docker info
Server:
 Containers: 3
  Running: 3
  Paused: 0
  Stopped: 0
 Images: 27
 Server Version: 20.10.22
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 ...
 ...
 Kernel Version: 5.15.0-56-generic
 Operating System: Ubuntu 22.04.1 LTS
 OSType: linux
 Architecture: x86_64

但是我在DinD映像中运行了docker info

# DinD machine
# docker info
Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 20.10.5+dfsg1
 Storage Driver: vfs
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 ...
 ...
 Kernel Version: 5.15.0-56-generic
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: x86_64

我不确定为什么DinD容器将存储驱动器用作vfs而不是overlay2。在DinD容器中。没有daemon.json的设置

# Inside DinD container (debian-11)
root@d7f083938722:/# cat /etc/docker/daemon.json 
{
  "data-root": "/data/var/lib/docker",
  "live-restore": true,
  "log-driver": "json-file",
  "init": true
}
xzlaal3s

xzlaal3s1#

在构建dind docker映像时。我安装了这个卷
停靠文件

VOLUME [ "/data/var/lib/docker" ]

因为我的daemon.json(目录/变量/库/停靠器/daemon. json)

daemon.json
{
    "data-root": "/data/var/lib/docker",
    "live-restore": true,
    "log-driver": "json-file",
    "init": true,
}

但是在运行docker映像时,我将主机卷安装在了dinddocker容器中的错误位置

docker run --privileged
  --mount type=volume,source=dind-var-lib-docker,target=/var/lib/docker ....
...

正确的运行命令应为

docker run --privileged
  --mount type=volume,source=dind-var-lib-docker,target=/data/var/lib/docker ....
...

修复卷装载后,dind容器使用主机系统配置overlay2

相关问题