DEV Community

Arne
Arne

Posted on

1

How to publish UDP ports with Docker-Swarm

I am sure you know those requests, where you think: Hey no problem, i have done this thousand times, give me 5 minutes and it will work.

The same happened last week, when a teammate from zisops asked me to publish a UDP Port for a already running Docker Swarm Service. I have done this 100 times before for "normal" Docker Containers. But hey.. Docker Swarm can't handle this with:

-p 500:500/udp

Ok next step: RTFM but hey.. nothing about publishing a UDP Port for a service. Next try: Start to google.. Gotcha, found a solutions in an Github Issue from the Moby Project. So if you ever have to use UDP with Docker-Swarm remember this small article, and buy me a beer :-)

Solution

docker service create --name my_service \
    --publish mode=host,published=500,target=5004,protocol=udp \
    my_image

Original post in german: https://www.geekpub.de/2017/10/docker-swarm-udp-port-freigeben-fuer-einen-service/

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay