DEV Community

Arne
Arne

Posted on

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/

Top comments (0)