containers - docker run with -p and a single port (instead of mapping) -


what different between following commands when creating container in docker?

docker run -d -p 8080 sample/image

and

docker run -d -p 8080:8080 sample/image

i have seen majority of them use second command, not sure if mean different things, or if first shorthand.

i couldn't find material on this.

docker run -d -p 8080 sample/image 

exposes port 8080 of container arbitrary port on host. port is docker.

whereas,

docker run -d -p 8080:8080 sample/image 

exposes port 8080 of container port 8080 on host.


in both cases, can see mapping using docker inspect, or docker ps:

380af8c2bcc6  ubuntu  "bash"  15 seconds ago  13 seconds  0.0.0.0:32768->1234/tcp elegant_meitner      

in case, port 1234 of container exposed port 32768 on host.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -