Docker compose extended ports format makes no distinction between TCP or UDP protocols

Hello everyone,

I am currently running Caddy as reverse proxy in docker. For streaming purposes I would like to publish port 443/udp, however, docker thinks this port is already in use because I publish port 443/tcp.

Compose ports section looks like this:

ports:
    - target: 80
      published: 80
      protocol: tcp
      mode: host
    - target: 443
      published: 443
      protocol: tcp
      mode: host
    #- target: 443
    #  published: 443
    #  protocol: upd
    #  mode: host
    - target: 2019
      published: 62019
      protocol: tcp
      mode: host

When I uncomment the UDP port I get the following error:

Error response from daemon: rpc error: code = InvalidArgument desc = EndpointSpec: duplicate published ports provided

Is this a bug or is there another way I need to tell docker to open the port with udp and tcp?

Thanks in advance!

You defined “upd” not “udp” . If it was just a mistake in the example, then the question is: did you try it with other ports as well. Since it worked for me, the second question is how did you install Docker and Compose, what versions you are using and on what platform?

And the last question is, can you just not use the “protocol” field if you want to forward both protocols and to the same internal port? The “protocol” field is optional.

update:

I tried the long syntax without the protocol and it forwards only tcp despite what the documentation says

1 Like

Boy, do I feel stupid. It was indeed the typo that I made that was causing the problem. I assume that Docker will default to TCP, which is probably why I got the duplicate error.