dockerstorageoverlayvfsdocker-in-docker

Docker in Docker(DinD) image uses vfs storage driver instead of overlay2


I have a docker in docker(DinD) images with debian-11 bullseye. On my host machine when I ran the command 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

But I ran docker info inside the DinD image.

# 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

I am not sure why DinD container is using storage drive as vfs instead of overlay2. Inside the DinD container. There are no setting for 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
}

Solution

  • While building dind docker images. I have this volume mount

    Dockerfile

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

    because my daemon.json (cat /var/lib/docker/daemon.json) is

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

    But while running the docker image. I was mounting the host volume at wrong location inside the dind docker container

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

    The correct run command should be

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

    After fixing volume mount the dind container is using host system configuration which is overlay2