简体   繁体   中英

Jenkins running in Docker Container but unable to launch it on browser

I have docker installed on Google cloud and I have pulled the Jenkins image from Docker Hub to my docker. Now when I am running a container with Jenkins image using below mentioned command its showing "INFO: Jenkins is fully up and running". But when I tried it on a browser with " http://cloud_external_ip:port " it is not getting opened. It's throwing the message: "This site can't be reached".

docker container run -p 80:80 --name myjen jenkins

have you tried to check your firewall-rules from the Cloud Shell, for example:

$gcloud compute firewall-rules list | grep 80 

then if you need to setup new rule:

$gcloud compute firewall-rules create default-allow-http --allow tcp:80

for more info you can take a look at Google Doc

The Jenkins default port is 8080. You can find out all the ports mapped in your docker using:

$ docker ps -l

or only for one container:

$ docker port myappname

and in the results you need to search for Jenkins and ExposedPorts, and looks similar to this:

“ExposedPorts”: {
“8080/tcp”: {}
 },

If you didn't change the default port for Jenkins and you was using this documentation during the installation it's possible that your Jenkins is working on 8080 port.

After check your ports if you want/need to change it in Jenkins you have two options:

  • by command: java -jar jenkins.war --httpPort=80
  • Modifying Jenkins config file: /PATH/jenkins , search for HTTP_PORT , and you add your selected port: HTTP_PORT = 80

You need to restart the service after modify the parameter.

If you want to use the port 8080 make sure that you have the correct firewall rules in GCP for this port. You can use the commands appointed by @J.Rojas.

If you're running a web app inside a docker container then before browsing it into the web browser you'll need to do PORT MAPPING.

Instead of running

docker run jenkins

Run this

docker run -p 8080:8080 jenkins

This will map your localhost to the internal IP of the container and you can access the application easily.

To change the port you can do:

docker run -p 8356:8080 jenkins

It can be accessed on port 8356. Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM