How can I expose more than 1 port with Docker?

So I have 3 ports that should be exposed to the machine’s interface. Is it possible to do this with a Docker container?

  • How can i run a script before destroy a docker container?
  • Unsatisfiable constraints when installing packages on docker alpine
  • How to check that a local URL is reachable
  • Docker named volume not updating
  • Docker swarm node hostnames are the same
  • How run Docker with sync folder on Windows
  • install local docker registry on centos 7
  • unable to run docker container (image size 9 GB) from AWS instance
  • A jenkins-slave container image per module type or a single centralized one which can build anything?
  • Docker swarm, unable to pin image to digest upon service create
  • Docker reloading certificate
  • Error starting docker postgres on travis-
  • 3 Solutions collect form web for “How can I expose more than 1 port with Docker?”

    To expose just one port, this is what you need to do:

    docker run -p <host_port>:<container_port>

    To expose multiple ports, simply provide multiple -p arguments:

    docker run -p <host_port1>:<container_port1> -p <host_port2>:<container_port2>


    In your Dockerfile, you can use the verb EXPOSE to expose multiple ports.

    EXPOSE 3000 80 443 22


    You then would like to build an new image based on above Dockerfile.

    docker build -t foo:tag .


    Then you can use the -p to map host port with the container port, as defined in above EXPOSE of Dockerfile.

    docker run -p 3001:3000 -p 23:22

    In case you would like to expose a range of continuous ports, you can run docker like this:

    docker run -it -p 7100-7120:7100-7120/tcp 

    if you use docker-compose.ymlfile:

                - 80
                - 6081

    You can also specify the host/network port

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