Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.
Michael Riedmann edited this page Dec 14, 2022 · 5 revisions

This Page is a loose collections of tasks users found worth sharing. If you think something is missing here, just add it under a new headline.

Add a mirror-registry

Sometimes you have to use internal mirror-registries (especially since the pull-policy change on docker.io). To do this you have to change the daemon.json config-file and restart docker-in-wsl. To access the right directory just execute docker-wsl show-config and edit the daemon.json file (be careful with line-endings - use a proper code-editor like VSCode or Notepad++).

Example:

{
  "registry-mirrors": [
    "https://docker-mirror.internal.example.com/"
  ]
}

Sync Env-Vars from Win32 to WSL

How to use env-vars set in windows in places "inside" the docker disto (e.g. Vars for docker-compose files)?

TL;DR Use the WSLENV variable to share environment-variables between wsl and windows. See https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/ for details on how to use this.

Sometimes you what to share environment-variables between windows and whatever you are running inside WSL (like docker in this case).

To share for example an IMAGE_VERSION envvar with docker-compose you can set the WSLENV variable to IMAGE_VERSION/u doing SET WSLENV=IMAGE_VERSION/u. After that, all wsl commands (in the same cmd-session) should have access to the content of IMAGE_VERSION via $IMAGE_VERSION.

To add more variables just concatenate them with : like so SET WSLENV=IMAGE_VERSION/u:DB_PASSWORD/u. The /u tells WSL to sync from Win32 to WSL not touching the content of the variable. There are other flags to handle path-conversion, multiple paths, and so on. Please read the official article linked above for more information.

Clone this wiki locally