Philip K. Adetiloye
Philip K. Adetiloye

Reputation: 3270

Docker-compose open all ports

I'm am deploying an app inside a docker container that randomly assigns ports when it starts. The problem is I want to use docker-compose but is there a way to expose all ports for the service using docker-compose? Without docker-compose, I would use docker run ... -P

Thanks

Upvotes: 17

Views: 19191

Answers (2)

amirb
amirb

Reputation: 447

I'd recommend using port ranges i.e

ports:
   - "1-65535:1-65535"

You will probably need to tinker with this range according to your app specifications so that you won't accidentally expose something that's already in use by the host (such as SSH).

Upvotes: 23

Kumar
Kumar

Reputation: 41

docker-compose version 1.25.0


Use it like following


ports: [22, 23]

It needs to be array of port numbers.

Upvotes: 1

Related Questions