Home > Enterprise >  Docker in WSL2 Alpine without Docker Desktop
Docker in WSL2 Alpine without Docker Desktop

Time:05-29

Docker under WSL1 without Docker Desktop is not possible, so I'm trying to run Docker from within WSL2 Alpine by following this article.

However I'm not that lucky to get it working. Fully log included below.

Anyone know where thing went wrong please?

The whole thing is done under alpine/v3.15 (installed from https://apps.microsoft.com/store/detail/alpine-wsl/9P804CRF0395?hl=en-us&gl=US) --

Downloading : https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-minirootfs-3.15.0-x86_64.tar.gz

% apk del docker-cli docker-ce docker-openrc docker-compose docker
ERROR: No such package: docker-ce

% apk del docker-cli docker-openrc docker-compose docker
(1/17) Purging containerd-openrc (1.5.11-r2)
(2/17) Purging iptables-openrc (1.8.7-r1)
(3/17) Purging ip6tables-openrc (1.8.7-r1)
(4/17) Purging docker-openrc (20.10.16-r0)
(5/17) Purging docker (20.10.16-r0)
(6/17) Purging docker-engine (20.10.16-r0)
(7/17) Purging containerd (1.5.11-r2)
(8/17) Purging runc (1.1.2-r1)
(9/17) Purging ip6tables (1.8.7-r1)
(10/17) Purging tini-static (0.19.0-r0)
(11/17) Purging docker-cli (20.10.16-r0)
(12/17) Purging ca-certificates (20211220-r0)
Executing ca-certificates-20211220-r0.post-deinstall
(13/17) Purging libseccomp (2.5.2-r0)
(14/17) Purging iptables (1.8.7-r1)
(15/17) Purging libnftnl (1.2.1-r0)
(16/17) Purging libmnl (1.0.4-r2)
(17/17) Purging device-mapper-libs (2.02.187-r2)
Executing busybox-1.34.1-r3.trigger
OK: 11 MiB in 22 packages

% sudo apk add docker --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
-ash: sudo: not found

% apk add docker --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
(1/17) Installing ca-certificates (20211220-r0)
(2/17) Installing libseccomp (2.5.2-r0)
(3/17) Installing runc (1.1.2-r1)
(4/17) Installing containerd (1.6.4-r2)
(5/17) Installing containerd-openrc (1.6.4-r2)
(6/17) Installing libmnl (1.0.4-r2)
(7/17) Installing libnftnl (1.2.1-r0)
(8/17) Installing iptables (1.8.7-r1)
(9/17) Installing iptables-openrc (1.8.7-r1)
(10/17) Installing ip6tables (1.8.7-r1)
(11/17) Installing ip6tables-openrc (1.8.7-r1)
(12/17) Installing tini-static (0.19.0-r0)
(13/17) Installing device-mapper-libs (2.02.187-r2)
(14/17) Installing docker-engine (20.10.16-r0)
(15/17) Installing docker-openrc (20.10.16-r0)
(16/17) Installing docker-cli (20.10.16-r0)
(17/17) Installing docker (20.10.16-r0)
Executing docker-20.10.16-r0.pre-install
Executing busybox-1.34.1-r3.trigger
Executing ca-certificates-20211220-r0.trigger
OK: 238 MiB in 39 packages

% service docker restart
 * WARNING: docker is already starting

% service docker status
 * You are attempting to run an openrc service on a
 * system which openrc did not boot.
 * You may be inside a chroot or you may have used
 * another initialization system to boot this system.
 * In this situation, you will get unpredictable results!
 * If you really want to do this, issue the following command:
 * touch /run/openrc/softlevel

% touch /run/openrc/softlevel
touch: /run/openrc/softlevel: No such file or directory

% service openrc start
 * service: service `openrc' does not exist

% service docker-openrc start
 * service: service `docker-openrc' does not exist

CodePudding user response:

You could just run the Docker daemon as noted in the blog post you linked to:

sudo dockerd

Then switch to another WSL Alpine instance and run the Docker client commands.

But to use the OpenRC Docker service, you have two options.

First, you can start OpenRC and then start the Docker service manually:

openrc default
rc-service docker start # or service docker start

Or you can add the Docker service to the default runlevel (one-time), and then it will run whenever OpenRC is started in that runlevel:

One-time:

rc-update add docker default

Then, to start OpenRC with the default runlevel, which will also run Docker:

openrc default

Really, it seems the only thing you were missing is that OpenRC wasn't initialized first. Normally, that would be done during Alpine init, but WSL's own /init is running instead.

  • Related