docker run -p "8080:8080" myApp
docker run -p "192.168.1.12:80:80" nginx
docker run -P myApp
In order to use ports on the host have been exposed in an image (via the EXPOSE
Dockerfile directive, or --expose
command line option for docker run
), those ports need to be bound to the host using the -p
or -P
command line options. Using -p
requires that the particular port (and optional host interface) to be specified. Using the uppercase -P
command line option will force Docker to bind all exposed ports in a container's image to the host.