I am trying to run jenkins container. I used "docker run --restart always --name myjenkins -p 8080:80 jenkins" but cannot access jenkins at http://localhost:8080 on browser. If I use docker run --restart always --name myjenkins -p 8080:8080 jenkins, I can access the jenkins url.
Thanks in advance
Each application must use a different port.
You can access to your application using directly its ports (if are available of course):
Applications could use any port because each one "is a different world"
You can not access to your docker applications using its internal ports:
Because for instance, 8080 of APP_B is only visible inside APP_B container. No body can access to this applications.
In order to access to your docker applications, You must explicitly establish a relationship between:
Linux host ports <->
inside containers ports.
To do that you could use -p parameter
After this you could access to your docker applications using its new ports :
Also a common error when docker-compose & docker network are used is use localhost instead ip when a docker app needs to connect to another docker app. As you can see you need to use ip or domain + external port instead localhost:8080
what is the difference between publishing 8080:80 and 8080:8080 in a docker run?
You just need to research what is the internal container port used by your jenkins and put it in docker run -p ...
8080:80 refers that in the container you are using port 80 and you are forwarding that port to host machine's 8080 port. So you are running Jenkins on port 80 inside your container wherever in scenario 2 you are running Jenkins on port 8080 inside the container and exposing it over the same port on host machine. For example if I am running mysql in container I may use 8080:3306 so mysql would be running on port 3306 but exposed on 8080 of host machine but if choose it to be 8080:80 for mysql it may not work because as per the code of mysql it binds itself on port 3306 not port 80. Same is the scenario in your case of Jenkins too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With