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:

  • docker registry v2 : get parent image name
  • Undertsanding docker build
  • Dokku Dockerfile - Cache node_modules / Bower Components
  • Multiple projects (and fig.yml) linking to same database
  • (spotify) Maven docker builder for Java
  • Access host machine dns from a docker container
  • 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?

  • Mounting private GitHub repository into a pod's volume
  • Why isn't nginx handling requests in this docker-compose/django setup?
  • Running multiple docker containers in same host
  • Access docker container running in coreos on vagrant vm through browser in host ubuntu host
  • TeamCity configuration doesn't persist inside docker
  • Jenkins: running docker commands on a docker slave
  • 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.