where is hostconfig.json (Docker desktop + WSL2 environment)

docker, wsl-2

Solution

Where it can be accessed

`hostconfig.json` for a container can be found in WSL2 using Windows Explorer at the hidden network path `\\wsl$\docker-desktop-data\version-pack-data\community\docker\containers\{containerid}\hostconfig.json`

Windows Explorer Screenshot with hostconfig.json

Where it is not (but may be expected)

The subdirectories of `/mnt/wsl/docker-desktop-data/version-pack-data` are not exposed to WSL (for some reason):

deno@DeonJ-T570:/mnt/wsl/docker-desktop-data/version-pack-data$ sudo ls -al
[sudo] password for deno: 
total 0
drwxr-xr-x 2 root root  40 May 25 12:09 .
drwxr-xr-x 6 root root 120 May 25 12:09 ..
deno@DeonJ-T570:/mnt/wsl/docker-desktop-data/version-pack-data$ 

Problem

As I know, docker doesn't support any command that change port mapping after make container. But this answer said that by changing the hostconfig.json file, I can change port mapping. How do I assign a port mapping to an existing Docker container? I'm using docker desktop in windows + WSL2.So path of hostconfig.json is different with other answers. Where is hostconfig.json? In my case, (\wsl$\docker-desktop-data\mnt\wsl\docker-desktop-data\data, /var/lib/docker(in wsl)) directories are not exist.

Original source

Related problems