Docker container with multiple configurable ports

I have a container that runs a node app with three servers: one server for public data and two webpack servers. By default these run on ports 3000, 3001, and 3002, but these ports can all be configured.

It seems that I would be able to run the container like so:

  • ERROR: In file './docker-compose.yml', service 'volumes' must be a mapping not an array
  • Simple Flask application with debug set to True is not reloading in Docker?
  • quay.io/etcd Container Command not found
  • Docker Sidekiq Starting - Rails App with Puma
  • Accessing Secrets/Private Files Needed for Building in Dockerfile?
  • Docker Continuous Integration with AWS
  • docker run -p 3000:3003 -p 3001:3004 -p 3002:3005 -e 'APP_PORT=3003' \
      -e 'NG_PORT=3004' -e 'RC_PORT=3005' --expose 3003 --expose 3004 --expose 3005 \
      ajcrites/webf
    

    However there are two problems with this approach:

    1. There is a tremendous amount of redundancy
    2. I want the default ports to be used/exposed if nothing is specified

    Is there a simpler way to expose all of the configurable ports whether or not they are changed from the defaults?

  • NodeJS + Mysql with Docker Compose 2
  • Connecting to MySql on Docker
  • Docker. How to get bash\ssh inside runned container (run -d)?
  • How to get from Android Emulator to Docker Machine's container?
  • How to add private registry certs to Docker Machine
  • Docker CMD with envsubst and tee
  • One Solution collect form web for “Docker container with multiple configurable ports”

    You wouldn’t want to expose ALL ports, however you can expose and bind by range since at least docker 1.5:

    docker run -p 3000-3002:3003-3005
    

    I don’t think you need to use –expose when you publish.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.