Running Docker on Windows without Docker Desktop

I wanted to run Aspire and Testcontainers from Windows without installing Docker Desktop. I’d love to see wslc take off as the native container experience on Windows, but a lot of tooling still expects the docker command or the Docker API.

Docker Desktop is the usual way to get a Docker endpoint on Windows, and some uses require a paid subscription. I run Docker Engine in Debian under WSL 2 and connect to it from Windows over localhost. The Windows Docker CLI and Testcontainers can both use that endpoint.

Install Docker Engine in WSL

I use Debian 13. From PowerShell, run wsl --list --verbose and check that your distribution is running on WSL 2. Take note of its name while you’re there. You’ll need it to find the client certificates from Windows.

Inside Debian, run ps -p 1 -o comm= to check that systemd is running. If the output is something other than systemd, enable systemd in WSL before continuing.

Follow Docker’s instructions to install Docker Engine on Debian, then run sudo docker run --rm hello-world inside Debian. Once that works, you have an engine to connect to from Windows.

Create the TLS certificates

The Docker API can give a client root access inside the distro, so I bind it to loopback and require mutual TLS. Windows verifies the daemon’s certificate, and the daemon only accepts TCP clients with a certificate signed by the same CA. Treat the client key like a root password.

Run the following in Debian as your regular user. OpenSSL will ask you for a passphrase for the CA key and prompt for it again each time you sign a certificate. The server certificate includes localhost and 127.0.0.1 as subject alternative names because those are the names the client can use to reach the daemon.

umask 077
mkdir -m 700 "$HOME/.docker-wsl-pki"
cd "$HOME/.docker-wsl-pki"

openssl genrsa -aes256 -out ca-key.pem 2048
openssl req -new -x509 -sha256 -days 3650 -key ca-key.pem -out ca.pem \
  -subj '/CN=Docker WSL CA' -addext 'basicConstraints=critical,CA:TRUE' \
  -addext 'keyUsage=critical,keyCertSign,cRLSign'

openssl req -new -newkey rsa:2048 -noenc -keyout server-key.pem -out server.csr \
  -subj '/CN=localhost'
cat > server.ext <<'EOF'
subjectAltName = DNS:localhost,IP:127.0.0.1
extendedKeyUsage = serverAuth
EOF
openssl x509 -req -sha256 -days 365 -in server.csr -out server-cert.pem \
  -CA ca.pem -CAkey ca-key.pem -CAcreateserial -extfile server.ext

openssl req -new -newkey rsa:2048 -noenc -keyout key.pem -out client.csr \
  -subj '/CN=docker-windows-client'
printf '%s\n' 'extendedKeyUsage = clientAuth' > client.ext
openssl x509 -req -sha256 -days 365 -in client.csr -out cert.pem \
  -CA ca.pem -CAkey ca-key.pem -CAserial ca.srl -extfile client.ext

Put the daemon’s files under /etc/docker/tls, and put the three files Windows needs in a directory under your Linux user’s home. The CA signing key stays in the private working directory. Keep it there for when you need to renew the server and client certificates.

sudo install -d -o root -g root -m 700 /etc/docker/tls
sudo install -o root -g root -m 600 ca.pem server-cert.pem server-key.pem /etc/docker/tls/

install -d -m 700 "$HOME/.docker-wsl-client"
install -m 600 ca.pem cert.pem key.pem "$HOME/.docker-wsl-client/"

Let Docker listen on localhost

Run sudo systemctl edit docker.service in Debian and add the following override. The blank ExecStart= clears the packaged command. The next line keeps the systemd-managed Unix socket and adds a TCP listener on port 2376, the usual Docker port for TLS.

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://127.0.0.1:2376 --containerd=/run/containerd/containerd.sock \
  --tlsverify --tlscacert=/etc/docker/tls/ca.pem \
  --tlscert=/etc/docker/tls/server-cert.pem --tlskey=/etc/docker/tls/server-key.pem

If you previously added a hosts setting to /etc/docker/daemon.json, remove that setting before restarting. Docker refuses to start when it gets its listener configuration from both places.

sudo systemctl restart docker.service
sudo ss -ltnp 'sport = :2376'

You should see dockerd listening on 127.0.0.1:2376. If it didn’t start, check sudo journalctl -u docker.service -n 30 --no-pager. Keep the Debian shell open while trying the Windows commands below. The Docker service alone won’t keep the distro running.

Connect from Windows

On Windows x64, extract docker.exe from Docker’s standalone ZIP and add the directory containing it to your PATH. Open a new PowerShell window so it picks up the change.

For Aspire builds that use a Dockerfile, you’ll also need Buildx on Windows. Download the windows-amd64 binary from the Buildx releases, rename it to docker-buildx.exe, and put it in %USERPROFILE%\.docker\cli-plugins. Create that directory if necessary, then run docker buildx version to check that Docker found it.

In Windows, open System → Advanced system settings. On the Advanced tab, select Environment Variables… and add or edit these entries under User variables.

VariableValue
DOCKER_HOSTtcp://127.0.0.1:2376
DOCKER_TLS_VERIFY1
DOCKER_CERT_PATH\\wsl.localhost\Debian\home\<linux-user>\.docker-wsl-client

Replace Debian with your distribution name and <linux-user> with the username you use inside it (whoami in Debian). If your Linux home is somewhere other than /home/<linux-user>, use its actual path in the share.

Close and reopen your terminal so PowerShell picks up the new values. Restart your IDE too if it was already open. Then check the connection from PowerShell.

docker version
docker run --rm hello-world

docker version should show a Windows client and a Linux server. If it can’t connect, check that Debian is still running and that Test-NetConnection 127.0.0.1 -Port 2376 succeeds. If the port is reachable and Docker reports a certificate error, check that DOCKER_CERT_PATH points to the directory containing ca.pem, cert.pem, and key.pem.

I’ve used this setup with Aspire and Testcontainers for .NET. Once hello-world runs, you can start your AppHost or run dotnet test from PowerShell or your IDE.