Compose: Docker compose's ports doesn't map host range mapping to single container port

Created on 17 Mar 2016  Â·  9Comments  Â·  Source: docker/compose

To map a container's port within a range of host's ports, Docker run acceps -p x-y:cPort, however it seems the option is not supported by Docker compose's yml file.

areconfig kinparity

Most helpful comment

Any news about this? I really need that...

All 9 comments

Yes, we should support this.

Is there any workaround to do the same with docker compose?

Not at present - you'll have to use docker run for the time being.

At docker cli also is failing because at https://github.com/docker/docker-py/blob/master/docker/utils/ports/ports.py#L77 is a check:

        if len(internal_range) != len(external_range):
            raise ValueError('Port ranges don\'t match in length')

Is this fix in the near term roadmap?

For those who need to have that feature, there is a workaround:
Docker uses ephemeral port range, so if you change that range you can actually define a range of ports to be used by docker but remember that it's a global config and might affect other tools running on the machine too.
To change the range you just need to run the following command as root:
echo MIN_PORT MAX_PORT > /proc/sys/net/ipv4/ip_local_port_range

where MIN_PORT and MAX_PORT define the port range.

@farhadkzm What if I'm using Docker for Mac?

From what I saw in the docker compose source code, I think it doesn't
support the feature on Mac neither.

Regards,

Farhad Kazemi

On 22 September 2016 at 11:17, Theodore Dubois [email protected]
wrote:

@farhadkzm https://github.com/farhadkzm What if I'm using Docker for
Mac?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/docker/compose/issues/3150#issuecomment-248788135,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFMrHb0nEH0i89AYbooD9Tq9m-QudLC1ks5qsdc1gaJpZM4HyrWo
.

Any news about this? I really need that...

Recent releases now support the p1-p2:p syntax (via #4649)

Was this page helpful?
0 / 5 - 0 ratings