Docker on WSL 2

I did wonder that one of the biggest motivations for WSL 2 would be improved Docker support when building Linux images on Windows. Glad to report that this appears now to be seamless.

When building Linux Docker images on Windows this message would appear:

SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

I noted earlier that Docker for Windows automatically detected the availability of WSL 2 and configured itself accordingly. I found that the docker command was already available. Looking at the output of htop it is clear that this is running a proxy with the Docker for Windows install.

/mnt/wsl/docker-desktop/docker-desktop-proxy --distro-name Ubuntu-20.04 --docker-desktop-root /mnt/wsl/docker-desktop

Testing this out, I can use WSL 2 to build Linux images that I am preparing in Windows, avoiding the warning shown earlier. However, the warning would be expected to still apply when using the Windows file-system. Access to the WSL file-system from Explorer is done via \\wsl$.


Welcome to WSL 2

I’ve been waiting for Windows 10 to be ready to update, and receive WSL 2. Now it is here. Docker for Windows was nice enough to set-up with this automatically. I am setting up a fresh Ubuntu 20.04 install just now, to use with Windows Terminal.

I had enjoyed using WSL 1, and found it useful so far as it went. It was a bit slow, and not everything worked. WSL 2 takes a different approach, embedding a whole Linux kernel, instead of implementing a Linux kernel interface. I expect this to be very useful when working with Linux Docker images etc. Hopefully it will be more frictionless.