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:

  • connect robomongo to mongoDB docker container
  • Noob FED tries to run MeanJS app on docker port mapping throws error
  • Docker Run error with ENTRYPOINT
  • docker and image size limit
  • How to run a cron job inside a docker container
  • Setup & scale titan/cassandra on AWS EC2 using docker
  • 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?

  • Microservices in practice
  • How to properly start Docker inside Jenkins that is also running in Docker
  • maven plugin for docker (e.g. to run with needed db)
  • How to dockerize my play scala app?
  • data lost while restarting postgres with docker
  • Docker-Mongodb - How to connect to the mongo image in local(windows)
  • 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.