Doesn't work when host is a virtual machine

I’m trying to run docker:rc-dind-rootless on Alpine Linux 3.16 (running inside a VirtualBox VM)

I’ve followed the steps on the documentation, first, i’ve executed:

docker run --rm --privileged --name dind -dt docker:rc-dind-rootless

And then:

docker exec -it dind docker-entrypoint.sh sh

The socket is never created at /run/user/1000/docker.sock, instead DOCKER_HOST is set to tcp://docker:2376, consequently making Docker commands fail with the no such host message

When checking the logs, the following error message appears:

Signature ok
subject=CN = docker:dind client
Getting CA Private Key
/certs/client/cert.pem: OK
Device "ip_tables" does not exist.
ip_tables              32768  2 iptable_filter,iptable_nat
x_tables               49152  6 xt_conntrack,xt_MASQUERADE,xt_addrtype,iptable_filter,iptable_nat,ip_tables
modprobe: can't change directory to '/lib/modules': No such file or directory
open: No such file or directory
[rootlesskit:child ] error: executing [[ip tuntap add name tap0 mode tap] [ip link set tap0 address 02:50:00:00:00:01]]: exit status 1

Strangely enough, it works fine on my Arch Linux (bare-metal) host, running, below are the versions of Docker that i’m running on each environment:

  • bare-metal: Docker version 20.10.17 (build 100c70180f)
  • vm: Docker version 22.06.0 (build 3e9117b)

Any clue of what might be happening? i wonder if the Docker version mismatch between both environments might be the one to blame

So you have Alpine Linux installed in the virtual machine. Do I understand you correctly?

Docker would work in a virtual machine. The problem is more likely that you use Alpine linux which is a special distribution and it is not really supported. I would not use an RC version of the docker image either. Use a stable version.

You could use the Dockerfile of the Alpine based dind image to install everything on your Alpine in the VM that you see in the Dockerfile.

However the kernel in the container would be the same as on the host, so you will not find installing kernel modules in the Dockerfile and it looks like Alpine linux does not have /lib/modules which I don’t know how you could solve.

I had this error before, but I don’t remember why it happened. I think it was a mistake in my configuration and the default host is “docker”. You can try to set DOCKER_HOST when you run the container.

Thanks for the detailed explanation! i also think that’s something on Alpine’s side, i tried running the same commands on Artix Linux and Fedora (both VMs) and the problem didn’t happened