Skip to main content
This page sets up a runner in WSL2 that builds in containers. The runner runs as a service in a WSL2 distribution, and a Windows scheduled task starts that distribution when you log in. A runner installed in WSL2 does not use Docker Desktop. With Docker Desktop alone, outerlayer runner init refuses. Install Docker Engine inside WSL2, as this page shows, or run the runner image on Docker Desktop. OuterLayer has not tested the runner image on Windows end to end.

Before you start

You need:
  • WSL2 with a Linux distribution that runs nothing but the runner. Setup turns off Windows access in that distribution. After the restart you lose code ., explorer.exe and /mnt/c in it. Use another distribution for Windows tools.
  • The runner’s files in the distribution’s own file system. Keep the config file, its directory and Node.js out of /mnt. The service cannot start otherwise.
  • Everything in Before you start on the setup page.
Check these before you set up, because each one fails after the restart:
  • Git’s credential helper. Git Credential Manager for Windows stops working. Use a helper inside the distribution.
  • ~/.docker/config.json. Remove a "credsStore": "desktop.exe" key, which Docker Desktop leaves behind. With it, pulls and image builds fail.
  • The default user. A copy of a distribution made with wsl --export and wsl --import starts as root. Set [user] default= in that copy’s /etc/wsl.conf. Otherwise the service runs as root.

Set it up

  1. In a WSL2 shell, install and start Docker Engine 26 or later. Follow Docker’s instructions for your Linux distribution.
  2. Install Docker’s Buildx plugin, version 0.18 or later.
  3. Check the shell and the engine:
  4. From the same shell, follow Set up your first host. Run outerlayer runner init without sudo: under sudo, it makes no scheduled task.
  5. If setup says that it turned systemd on, run wsl --shutdown from Windows. Open the distribution again, and run outerlayer runner install --service --config ~/.outerlayer-runner/config.json.
  6. Restart the distribution, so the settings that turn off Windows access apply.
  7. Run outerlayer runner check --config ~/.outerlayer-runner/config.json. The hook provision line says builtin:container.
The commands on this page pass --config ~/.outerlayer-runner/config.json, as the setup page does. Leave it out if you saved the key with outerlayer login.

Restart the distribution

Setup writes the settings that turn off Windows access to /etc/wsl.conf. WSL reads that file only when the distribution starts, and setup does not restart it. Until you restart, Windows access stays on.
A restart stops every running build. Restart when no build runs.
Run these commands from Windows. Use the name that wsl -l shows for <distribution>.

Keep the runner running

WSL2 shuts a distribution down when no Windows program uses it. So setup makes two things:
  • A systemd unit inside WSL2, as on Linux. See Run the runner as a service.
  • A Windows scheduled task, outerlayer-runner. It starts the distribution when you log in and keeps it running.
The runner runs from when you log in, not before. For a runner that runs before anyone logs in, use Linux. Setup makes the task with schtasks.exe, through the distribution’s access to Windows. After the restart, that access is off. A later run of runner install --service or runner uninstall --service then prints the schtasks command to run in Windows:

Windows access from the runner’s distribution

Setup turns off three WSL2 defaults in the runner’s distribution. It writes them to /etc/wsl.conf and keeps every other line of the file:
  • Interop. With interop on, any Linux process in the distribution can start a Windows program. Windows runs it as the active Windows user.
  • The Windows PATH. WSL adds it to the distribution’s PATH, so a shell finds cmd.exe and powershell.exe by name.
  • Drive automount. WSL mounts each Windows drive under /mnt. A process can then read and change the drive with your Windows rights.
A build that escapes its container as an account other than root would reach your Windows account through these. The runner needs none of them after setup. The settings do not stop root. Root in the distribution can still mount a Windows drive by hand, and a drive listed in /etc/fstab still mounts at start. WSLg still shows windows on your desktop. The runner’s account is often in the docker group, which gives root in practice. A build that must never reach your Windows account needs microVM builds, which WSL2 does not offer. See WSL2. To apply these settings to a runner whose distribution does not have them, run outerlayer runner install --service --config ~/.outerlayer-runner/config.json. Then restart the distribution. To turn Windows access back on, delete the three lines and restart the distribution. runner uninstall --service leaves them in place, because another runner can share the distribution.

Check with outerlayer doctor

Run outerlayer doctor --config ~/.outerlayer-runner/config.json. Every other line is in outerlayer doctor.

Remove the runner

Follow Uninstall the runner. runner uninstall --service removes the unit and the scheduled task. If it cannot start schtasks.exe, run the remove command from the table above in Windows.