Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to forward a UDP port from a devcontainer?

I'm trying to use the "Node.js & Mongo DB" devcontainer from Microsoft (https://github.com/microsoft/vscode-dev-containers/tree/main/containers/javascript-node-mongo/.devcontainer) with my udp server made in Nodejs.

The problem is as follows: When i try to forward a port in devcontainer.json example : "forwardPorts": [1117].

It seems to only forward 1117/tcp when i actually want to forward 1117/udp.

I'm trying to making this work for this project : https://github.com/QuentinGruber/h1z1-server/blob/master/.devcontainer/devcontainer.json

like image 629
Qgruber Avatar asked Oct 23 '25 18:10

Qgruber


1 Answers

The documentation is kinda fuzzy regarding protocols used for exposed ports with forwardPorts tag:

forwardPorts

  • array
  • An array of ports that should be forwarded from inside the container to the local machine.

Because of that I would recommend trying to use the older appPort tag because when I looked here it said they're using the docker-compose syntax which means you can specify the ports and protocol like so:

docker-compose:

ports:
- "3000"
- "8921:5000"

devcontainers.json:

"appPort": [ 3000, "8921:5000" ]

And in your case:

"appPort": [ "1117:1117/udp" ]

According to the docs, using the appPort tag is also useful when you want to access the application (or expose the ports) to more than just localhost

like image 186
Noam Yizraeli Avatar answered Oct 25 '25 14:10

Noam Yizraeli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!