I’ve gone through several tutorials to make access to the application available via Network, but nothing has worked so far:
//devcontainer.json
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/javascript-node
{
"name": "node",
"build": {
"dockerfile": "Dockerfile",
"args": { "VARIANT": "18-bullseye", "network": "host" }
},
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"dbaeumer.vscode-eslint",
"anseki.vscode-color",
"GitHub.copilot",
"sainoba.px-to-rem",
"bradlc.vscode-tailwindcss",
"neptunedesign.vs-sequential-number",
"Wscats.vue"
]
}
},
"settings": {
"remote.localPortHost": "allInterfaces"
},
"forwardPorts": [8080],
"remoteUser": "node"
}
# DockerFile
ARG VARIANT=16-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
EXPOSE 8080
I also tried to add the settings in the settings of each environment local:
I can normally access from the local machine, but when I try to access through the cell phone, I can’t
I need to fix some problems in the mobile version, it would be nice to be able to access it directly via wi-fi, thanks in advance
Mac OS 12.4
Docker Desktop 4.9.1 (81317)
2
Answers
The IP address (172.17.0.2) you are using to access the frontend is probably the on the internal docker network. You should use the IP address of your Mac to connect from the wifi network. You can find this IP address in the network settings of your Mac.
You also need to make sure you publish the port 8080 on the outside Ip of your Mac. See docker docs
Hope this helps.
In devcontainer.json comment out:
And add:
You must rebuild the container to changes take effect. In vscode run: "Remote-Containers: Rebuild Container" command in the Command Palette (F1) when you are connected to the container.
Then you should be able to access from your mobile using http://192.168.0.10:8080
To put some context, we are trying to configure a remote container created with vscode and connect from the LAN. See devcontainerjson-reference and containers#_publishing-a-port