Update readmes regarding wsl2 devcontainer setup

This commit is contained in:
2025-11-30 22:07:29 +00:00
parent 5865d9dbe5
commit 3fa5bf8360
2 changed files with 20 additions and 16 deletions

View File

@@ -144,6 +144,9 @@ First get the WSL IP address by running the following command in WSL:
```sh ```sh
hostname -I hostname -I
# Or from Windows Command Prompt / PowerShell:
wsl hostname -I
``` ```
Then use the WSL IP address (in my case `172.20.39.187`) in the following command to set up permanent port forwarding. Then use the WSL IP address (in my case `172.20.39.187`) in the following command to set up permanent port forwarding.
@@ -152,8 +155,8 @@ Then use the WSL IP address (in my case `172.20.39.187`) in the following comman
# Add port forwarding rule # Add port forwarding rule
netsh interface portproxy add v4tov4 listenport=3000 listenaddress=127.0.0.1 connectport=3000 connectaddress=172.20.39.187 netsh interface portproxy add v4tov4 listenport=3000 listenaddress=127.0.0.1 connectport=3000 connectaddress=172.20.39.187
# In case you need to delete the rule later, use: # Just in case you need to delete the rule later, use:
netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=127.0.0.1 #netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=127.0.0.1
``` ```
You should now be able to access the React dev server via `http://localhost:3000` on Windows host, instead of having to use the WSL IP address. You should now be able to access the React dev server via `http://localhost:3000` on Windows host, instead of having to use the WSL IP address.
@@ -165,14 +168,12 @@ In case you have trouble with your Windows Firewall blocking access to the forwa
Run the following PowerShell commands to open the necessary port (just an example, ensure that the settings fit your security requirements): Run the following PowerShell commands to open the necessary port (just an example, ensure that the settings fit your security requirements):
```powershell ```powershell
# Open port 3000 for inbound TCP traffic on all network interfaces # Open port 3000 for inbound TCP traffic on WSL virtual network interface
New-NetFirewallRule -DisplayName "WSL React Dev Server" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3000 New-NetFirewallRule -DisplayName "Allow WSL Inbound Port 3000" `
-Direction Inbound -Action Allow -Protocol TCP -LocalPort 3000 `
# Do the same but only for the WSL virtual network interface -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))"
New-NetFirewallRule -DisplayName "Allow WSL Inbound Port 3000" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3000 -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))"
``` ```
In case the above does not resolve your issues, just to rule out potential firewall issues, it is always an option to temporarily disable the firewall all together.
Just to rule out potential firewall issues, it is always an option to temporarily disable the firewall all together.
> WARNING: IF YOU DO THIS, DO NOT FORGET TO RE-ENABLE THE FIREWALL AFTER TESTING! > WARNING: IF YOU DO THIS, DO NOT FORGET TO RE-ENABLE THE FIREWALL AFTER TESTING!

View File

@@ -14,6 +14,9 @@ sudo apt install -y podman
# Ensure Podman version is ≥ 4.9.3: # Ensure Podman version is ≥ 4.9.3:
podman --version podman --version
# Add current user to uucp group for Podman socket access
#sudo usermod -a -G uucp $(whoami)
``` ```
## ⚙️ 2. Enable systemd and Podman socket ## ⚙️ 2. Enable systemd and Podman socket
@@ -34,6 +37,10 @@ wsl --shutdown
Enable Podman socket: Enable Podman socket:
```bash ```bash
# Enable linger to allow user services to run without active login
# Without this, the command below may return: Failed to connect to bus: No such file or directory
loginctl enable-linger $USER
systemctl --user enable --now podman.socket systemctl --user enable --now podman.socket
``` ```
@@ -41,12 +48,7 @@ If `podman.socket` is masked or fails to start, create a custom service:
```bash ```bash
mkdir -p ~/.config/systemd/user mkdir -p ~/.config/systemd/user
vim ~/.config/systemd/user/podman.service cat > ~/.config/systemd/user/podman.service <<EOF
```
Paste:
```ini
[Unit] [Unit]
Description=Podman API Service Description=Podman API Service
Requires=podman.socket Requires=podman.socket
@@ -59,6 +61,7 @@ KillMode=process
[Install] [Install]
WantedBy=default.target WantedBy=default.target
EOF
``` ```
Reload and enable: Reload and enable:
@@ -71,7 +74,7 @@ systemctl --user enable --now podman.socket
Verify: Verify:
```bash ```bash
curl --unix-socket /run/user/1000/podman/podman.sock http://localhost/_ping #curl --unix-socket /run/user/1000/podman/podman.sock http://localhost/_ping
``` ```
## 🧠 3. Configure Podman registry (to avoid interactive prompts) ## 🧠 3. Configure Podman registry (to avoid interactive prompts)