Search code examples
dockerdocker-compose

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


Solution

  • 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).