Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
791 views
in Technique[技术] by (71.8m points)

jenkins - what is the difference between publishing 8080:80 and 8080:8080 in a docker run?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Without Docker

imagenro1

  • Each application must use a different port.

  • You can access to your application using directly its ports (if are available of course):

With Docker

enter image description here

  • 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.

enter image description here

To do that you could use -p parameter

  • docker run -d -p 8080:8080 APP_A ...
  • docker run -d -p 8081:8080 APP_B ...
  • docker run -d -p 8082:8080 APP_C ...

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?

  • With 8080:80 you expect that your application uses or start with the 80 internal port inside container.
  • With 8080:8080 you expect that your application uses or start with the 8080 internal port inside container.

You just need to research what is the internal container port used by your jenkins and put it in docker run -p ...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...