0

I have a container that runs a server that listens port 5000 for UDP connections. Dockerfile has EXPOSE 5000/udp set and when I run the container, I can see that PORTS has 5000/udp correctly.

However it doesn't work as expected because the client can't connect to it. To make matters even more confusing, netcat can connect to the port 5000 via udp just fine.

I can get everything to work by specifying -p 5000:5000/udp manually. This would be fine but I have to run this container in a swarm and --publish 5000:5000/udp doesn't seem to do the trick.

Any ideas what I'm doing wrong here?

jimmy
  • 121
  • 1
  • 5

1 Answers1

0

After some digging I finally found an answer. EXPOSE doesn't "publish" the port so you have to publish the port with -p. The problem, at least for me, was that in swarm the port wasn't get published right in replicated mode.

The solution was to create a service in global mode and set publishing mode to host:

--publish published=5000,target=5000,protocol=udp,mode=host --mode=global

jimmy
  • 121
  • 1
  • 5