Skip to content

Instantly share code, notes, and snippets.

@edjdavid
Last active December 3, 2023 14:50
Show Gist options
  • Save edjdavid/05caa102318bcd3823b89c17b155d8d7 to your computer and use it in GitHub Desktop.
Save edjdavid/05caa102318bcd3823b89c17b155d8d7 to your computer and use it in GitHub Desktop.
Docker on WSL without installing Desktop
  1. In Windows:

Make sure WSL version is >= 0.67.6

wsl --version

* Uninstall Docker Desktop if installed previously.

  1. In Ubuntu (or any WSL Distro):

Modify /etc/wsl.conf and add

[boot]
systemd=true
  1. In Windows:

Restart WSL

wsl --shutdown

* WSL will restart when opening a new WSL shell

  1. In Ubuntu:

Install Docker Engine

Notes:

  1. If the internal docker network conflicts with other networks like VPN, modify or create /etc/docker/daemon.json and set the Bridge IP (BIP) and address pools to any available address
{
  "bip": "192.168.2.1/24",
  "default-address-pools": [
    {
      "base": "192.168.4.0/22",
      "size": 24
    }
  ]
}
  1. To avoid the Windows services from hanging/stalling, limit the maximum RAM that can be used by WSL

In Windows:

Modify ~/.wslconfig, add:

[wsl2]
memory=4GB

Change memory to reserve around 2-4GB exclusively for Windows (e.g. for 16GB RAM, 12-14GB will be a good setting)

  1. Error err: exec: "docker-credential-pass": executable file not found in $PATH

Docker Desktop has created a docker config with credstore set to the windows binary. Edit ~/.docker/config.json and remove the credstore or install one from https://github.com/docker/docker-credential-helpers and use the appropriate credstore name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment