Hi,
I am having an issue for getting access to contenarized web apps (React) from my web browser in Windows running in WSL2 without using docker desktop.
I don’t know what could be the problem. I did a bare installation of docker following this post.
If I run my React app normally (without container), I don’t have any issues with Windows and WSL2 (just put localhost:3000 in Chrome and I have access to my app). My default port forwarding dows the work and I am able to access my app from my browser. However, if I do the runn the same app in a container, I am not able to access it with a web browser. Weirdly, if I do a curl command to the containerized app inside WSL2 (curl http://localhost:3000), I get a response with the initial HTML of the. What could be the problem? I still can’t find the issue.
Below I show an example with you some outputs I got doing a test running an Apache Server mapped to port 80 in my localhost.
Details about my running containers (Zsh Shell - Ubuntu - WSL2)
➜ ~ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86e9b3e69415 httpd "httpd-foreground" 3 minutes ago Up 3 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp apache
Details from running curl in my Ubuntu distribution inside WSL (Zsh Shell - Ubuntu - WSL2)
➜ ~ curl localhost:80
<html><body><h1>It works!</h1></body></html>
Details about my WSL version (Powershell Windows)
PS C:\Users\samuelv> wsl --version
WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22621.3737
Details about my Linux Distribution (Zsh Shell - Ubuntu - WSL2)
➜ ~ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
For the example given above, if I try in this case to get to localhost in my browser (localhost:80 or localhost, both the same), I can’t get access. But with the curl command inside WSL2, I don’t have any issues. What could be the problem?