Docker Desktop WSL 2 Ports Access Denied
As I’ve been trying to work with Linux containers and images, I ran into a problem with assigning ports to Linux containers. The Linux distro is running under WSL 2 on my Windows 10 2004… and when I set the -P x:y, Docker would fail to start the container will an error Access denied.
So after lots of internet looking… and port mangling… noon of which work… I find that the Linux distro (Ubuntu 18 something) seems to require root… so here we go…
I open a bash terminal under the distro that docker is using… and do the following:
sudo groupadd docker sudo usermod -aG docker $USER sudo chown root:docker /var/run/docker.sock
Now the first groupadd should report that the docker group already exist… not a problem. This only means you are in the right distro…
The next two commands put the docker socks code under the ownership of root.
And there you go, one can assign ports in the run.
~SG