Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker run -p ?/? (what are this two port numbers and what they represents )

I used command "docker run -p 8080/8080 --name my_local_image ...." and it failed saying Unable to find image '8080/8080:latest' locally

8080/8080 = what this two port represents exactly ?

like image 796
Raj Kommawar Avatar asked Sep 05 '25 03:09

Raj Kommawar


1 Answers

Replace this " -p 8080/8080 " by this " -p 8080:8080 "

  • The first port : the Docker host ( you can use this port to access to your container) to access to the container from the outside.
  • the second one : is the port used by your application.

Example : I want to run tomcat server in a docker container, the default port of tomcat is 8080 and I want to expose my docker on port 9000 so i have to write :

docker run -p 9000:8080 --name myTomcatContainer tomcat 

So with this configuration I can access to Tomcat from outside using : http://host-ip:9000

like image 71
Imad Salki Avatar answered Sep 07 '25 19:09

Imad Salki