Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

wsl-2

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.

like image 533
Yunseong Jeon Avatar asked Jan 03 '21 02:01

Yunseong Jeon


People also ask

Where are Docker images stored WSL2?

Trouble finding docker image storage folder You can find these folders by opening your WSL Linux distribution and entering: explorer.exe . to view the folder in Windows File Explorer. Enter: \\wsl\<distro name>\mnt\wsl replacing <distro name> with the name of your distribution (ie. Ubuntu-20.04) to see these folders.

Where are Docker volumes stored Windows WSL2?

ls -l /var/lib/docker/volumes/ Beta Was this translation helpful?


1 Answers

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$ 
like image 200
Spastika Avatar answered Nov 29 '22 02:11

Spastika