How do i expose all open ports on a docker container?



  • Man page for docker run.

    Using the -P option:

           -P, --publish-all=true|false
              Publish all exposed ports to random ports on the host interfaces. The default is false.
    

    Run a container with the -P option.

    $ docker run -d -P nginx
    07d4faa53b188b49d4ea6cd48ba7d6f2e75eaa2d423f6a0a01aaa85945b70ec5
    

    Check the port mapping.

    $ docker port 07d4faa53b18 
    80/tcp -> 0.0.0.0:32773
    

Log in to reply
 

© Lightnetics 2024