App inside docker container can't be accessed from outside of the computer

85 Views Asked by At

I'm using a windows machine with WSL2. Docker Desktop and Docker Engine installed. I've been working on some projects using Docker Desktop for Windows that involve allowing users to connect from other devices. This hasn't been a problem until I've decided to switch to Docker Engine via WSL2. When I run a container on Docker Engine, it can only be accessed from localhost:port, not from machine_ip:port. This is the command I'm using to run an ignition container, which works fine on Docker Desktop but not so fine on Docker Engine:

docker run --name ignition -p 8085:8088 inductiveautomation/ignition:latest

Is there any reason preventing the ports from "opening" when using Engine vs Desktop?

I tried changing the port to -p 0.0.0.0:8085:8088 and setting -h 0.0.0.0. I also tried running a shiny app to see if the error had something to do with ignition but there was no success. Every container I run on Docker Engine only works on locahost.

I've also made sure to stop and even delete the containers I created on Docker Desktop with conflicting ports. Also, not sure if this is unrelated but when I start the WSL2 console and type docker context ps I see the containers running on Docker Engine, but if I start Docker Desktop and run the command, I see the Docker Desktop containers. I've checked the active context for both scenarios using docker context ls and the default context is always the active one (not desktop-linux nor desktop-windows).

0

There are 0 best solutions below