Search code examples
dockervisual-studio-codedocker-composedockerfilevscode-devcontainer

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


Solution

  • Fllowing the documentation you can forward udp protocol with this line

    docker run -p 53160:53160/udp docker/getting-started
    

    So trying add this to your configuration file and should works.

    References: docker network