9

In a Docker Compose file, I can easily publish a range of ports using the short-form syntax:

ports:
  - "3000-3010:3000-3010/udp"

But in my case, I need those ports as "mode=host" to bypass the swarm overlay network. The short-form syntax can't express that, so I need to use the long-form:

ports:
  - published: "3000-3010"
    target: "3000-3010"
    protocol: udp
    mode: host

However, it seems that Docker doesn't like specifying ranges with the long-form syntax, as I get that error when deploying a stack:

services.test.ports.0.target must be a integer

Is there a way to do that (except brute-force by specifying each and every port in the range as long-form) ?

2
  • 1
    Indeed great question (currently dealing with same issue)... Did you find an answer on it? Did you find solution to publish range of ports using the long form syntax?
    – cool
    Commented Dec 4, 2017 at 17:50
  • Try latest edge version - some people report improvements in 17.11.0-ce, at least ability to pass these values as an environment variable; or just wait for 17.12 which should be just around the corner. See this: github.com/docker/cli/issues/229
    – Ivan
    Commented Dec 6, 2017 at 15:10

1 Answer 1

8

This is not possible at the moment.

As per my discussion about this feature on official docker slack channel, exposing range of ports using long format syntax (which is the only syntax right now which you can use to publish ports in host mode) is not possible.

Having in mind that there is an open ticket related with this matter, I suppose it will be possible in near future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.