Windows Docker development without Docker Desktop

January 13, 2022    Development Windows Docker

Windows Docker development without Docker Desktop

It’s January, 2022 and with the licensing changes for Windows Docker for Desktop, I decided to learn how to run Docker without it using WSL 2. I have Windows 10. According to Docker “It remains free for small businesses (fewer than 250 employees AND less than $10 million in annual revenue), personal use, education, and non-commercial open source projects.”

I followed the instructions in How to run docker on Windows without Docker Desktop by Nicolas Louis . They worked! I am now able to run docker containers in Ubuntu and PowerShell Core in Windows Terminal.

Follow the instructions exactly.

There is other instructions from Docker to install on Ubuntu .

Consider trying Mr. Gnatowski’s scripts first/instead to simplify things. See that mention below. You’ll still need the Windows and VS Code extension instructions from above.

I had some proxy issues and had to make changes to /etc/wsl.conf and /etc/resolv.conf, but maybe Mr. Gnatowski’s scripts avoid this? Dakota helped me out again.

I had this Ubuntu resolv.conf

I think your /etc/wsl.conf should have this
And then add this to your /etc/resolv.conf (you might need to delete the existing and create a new one to get rid of the symlink)

And then I think you'll have to restart wsl (kill your shell and open a new instance) to verify your changes to resolv.conf are still there

If you are still having problems connecting with VPN or otherwise, there are several ideas from StackOverflow .

Now I can run it with docker -H {my IP} run -it ubuntu bash

Reminder {my IP} can be found from the given command

echo `ifconfig eth0 | grep -E "([0-9]{1,3}.){3}[0-9]{1,3}" | grep -v | awk '{ print $2 }' | cut -f2 -d:`

You’ll need to note the IP address from launching dockerd, then use that with -H tcp://{my IP} run in the future. You also use this in VS Code’s Docker Extension setup. I was going a bit too fast and missed that the first time.

In the comments, from Pawel Gnatowski on Sep 27 ‘21, he mentioned a more simple approach with port forwarding. This might be something to try before going through the article, but I didn’t see it until later. Check out his Github scripts . “How to run WSL2 and Hyper-V VMs as if your Linux was normal VM, with own ip address: no redirects needed. no special software. As it should have been from the start. or As if MS decided not to overwrite your config every single reboot.”

You may need to set it up to start Docker daemon automatically or another link , but after I closed and started Ubuntu again, it was already running.

Microsoft Learn has some info about VPN and internet problems .

Update in March 2023

I found wsl-vpnkit to be helpful. Follow the steps to install wsl-vpnkit the first time

Each day on VPN, I run these commands in Powershell.

wsl --shutdown
wsl -d wsl-vpnkit
wsl.exe -d wsl-vpnkit --cd /app service wsl-vpnkit start

Update September 2023

I had to setup a new laptop and found that with wsl-vpnkit v4.0.1, the systemd instructions are the way to go.

  1. Follow his instructions

  2. add to wsl.conf [boot] systemd=true

  3. systemctl status wsl-vpnkit (is it running and enabled now?)

  4. wsl.exe -l -v

  5. wsl --set-default wsl-vpnkit

kevin@A1:~$ cat /etc/resolv.conf
kevin@A:~$ cat /etc/wsl.conf
generateResolvConf = false
kevin@A1:~$ systemctl status wsl-vpnkit
● wsl-vpnkit.service - wsl-vpnkit
     Loaded: loaded (/etc/systemd/system/wsl-vpnkit.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-09-08 09:41:16 CDT; 4min 41s ago
   Main PID: 218 (wsl.exe)
      Tasks: 1 (limit: 19022)
     Memory: 296.0K
     CGroup: /system.slice/wsl-vpnkit.service
             └─218 /init /mnt/c/Windows/system32/wsl.exe /mnt/c/Windows/system32/wsl.exe -d wsl-vpnkit --cd /app wsl-vp>

I also found out after many trials that git clone in WSL worked where I had PHP composer docker-compose up issues when I git cloned into Windows, then docker-compose up in WSL (without Docker Desktop). It seems to run faster. The files can be access in Windows file explorer through \wsl.localhost\Ubuntu-20.04\home{username} which is cd ~ in WSL.

More Commands

Check if Docker is running with sudo service docker status, start it with sudo service docker start.

Automatically start docker with systemd running sudo systemctl enable docker once.

dockerd docs

Thanks to these referrals for pointing to this article

Watch the Story for Good News
I gladly accept BTC Lightning Network tips at [email protected]

Please consider using Brave and adding me to your BAT payment ledger. Then you won't have to see ads! (when I get to $100 in Google Ads for a payout, I pledge to turn off ads)

Use Brave

Also check out my Resources Page for referrals that would help me.

Swan logo
Use Swan Bitcoin to onramp with low fees and automatic daily cost averaging and get $10 in BTC when you sign up.