So …

What happened between yesterday and today that I seem to be giving Alpine WSL a second chance?

Well, Docker supremo Simon Ferquel himself responded to the Github issue I previously opened, Docker Desktop 2 not Creating Unix Socket on Alpine WSL 2 #5681, that’s what. So here we are. Simon’s response:

The proxy (as well as CLI binaries that we ship with docker-desktop) depends on glibc. You need to install a glibc package (such as https://github.com/sgerrand/alpine-pkg-glibc) on your alpine environment to make it work.

.

Installing Sasha’s GLIBC on Alpine

.

The Alpine package Simon links to, and the instructions to install it, are here: https://github.com/sgerrand/alpine-pkg-glibc. Below I’ll be following those instructions on a fresh install of Alpine WSL. Once I’m done installing glibc I will be re-attempting to connect from Alpine WSL to Docker Desktop. With luck, the Docker Desktop connection will be successful!

.

Install ca-certificates and wget packages:

Download install package key:

sudo wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub

Download package

Finally, install glibc:

.

IO Error When Installing from Windows Bind Volume Mounts

.

Initially when I tried to install the package I got an IO ERROR message:

I checked the directory where I downloaded the package to, and where I was running the local apk add command, and it was the Windows host mounted directory:

bash-5.0$ pwd
/mnt/c/Users/<my windows username>

After changing directory cd to $HOME , which in my case is /home/wsl and outside of the Windows bind mounts, I re-downloaded and attempted to install the package again. This time I had no issues.

.

Installing The Docker Client

.

Since this is a fresh Alpine WSL install, I have to install the Docker client in order to connect to Docker Desktop running on Windows.

Don’t install the docker Alpine package, that contains the whole Docker engine. Docker Desktop already installed the Docker Engine, and so you want to connect to that.

To install just the Docker client, which is what is needed to connect to Docker Desktop, use the Alpine docker-cli package:

sudo apk add docker-cli

If you try to connect right after into the Docker daemon, it won’t work:

This is perfectly normal. If this is a fresh Alpine WSL installation on Windows, you need to: 1) Make sure the Alpine distro is running on version 2 of WSL; 2) Docker Desktop is aware of, and integrated with the Alpine distro.

To verify that you have the correct distro version, from cmd.exe or PowerShell run wsl -l -v and ensure the VERSION column for the Alpine distribution has the number 2:

Legit: Alpine is using WSL version 2.

Then on the Docker Desktop end, ensure that the Enable the experimental WSL 2 based engine is enabled,

and that under Resources -> WSL INTEGRATION the desired WSL distribution is enabled, in this case Alpine:

By default, new distributions are disabled under WSL integration ^^
Go to Docker Settings and enable the WSL integration, then restart Docker.

Once I enable the Alpine distribution WSL integration, I click on Apply and Restart in order to restart Docker Desktop and the changes to hopefully take effect.

After restarting Docker Desktop, I close any Alpine WSL terminal session I have open. I then open a new Alpine WSL terminal and type docker images . What do I get:

I get a successful connection to Docker Desktop for Windows, from Alpine WSL 2:

All of that right at 11:58AM, right before noon, which makes it even better.

What a pleasant start to my day.

.

Thank you Simon Ferquel, not only for your next-day prompt response on my Github issue over at the Docker for Windows project, but also for all your incredible work over at Docker.

Thank you to Sasha Gerrand for providing an Alpine compatible glibc and making possible the ability to connect WSL 2 to Docker Desktop.

Barring any surprises, now my Visual Studio Code editor will be able to run on a PHP runtime that is the exact same as the as my production Docker workloads.

Thank you everyone else for following this journey so far.

.

Live from Bushwick, New York — Happy Dockerizing !

.

--

--

Callback Insanity
Callback Insanity

Written by Callback Insanity

Organic, fair-sourced DevOps and Full-Stack things. This is a BYOB Establishment — Bring Your Own hipster Beard.