Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish a range of ports with 'mode=host' with a Docker Compose file?

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) ?

like image 760
William H. Avatar asked Jul 19 '17 14:07

William H.


1 Answers

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.

like image 126
cool Avatar answered Oct 13 '22 11:10

cool