简体   繁体   English

Jenkins 在 Docker 容器中运行但无法在浏览器上启动它

[英]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.我在谷歌云上安装了 docker,并将 Jenkins 图像从 Docker Hub 拉到我的 docker。 Now when I am running a container with Jenkins image using below mentioned command its showing "INFO: Jenkins is fully up and running".现在,当我使用下面提到的命令运行带有 Jenkins 图像的容器时,它显示“信息:Jenkins 已完全启动并正在运行”。 But when I tried it on a browser with " http://cloud_external_ip:port " it is not getting opened.但是当我在带有“ http://cloud_external_ip:port ”的浏览器上尝试它时,它没有被打开。 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:您是否尝试过从 Cloud Shell 检查您的防火墙规则,例如:

$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有关更多信息,您可以查看Google Doc

The Jenkins default port is 8080. You can find out all the ports mapped in your docker using: Jenkins 默认端口为 8080。您可以使用以下命令找出在您的 docker 中映射的所有端口:

$ 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:在结果中您需要搜索 Jenkins 和 ExposedPorts,看起来类似于:

“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.如果您没有更改 Jenkins 的默认端口并且您在安装期间使用了此文档,则您的 Jenkins 可能正在 8080 端口上工作。

After check your ports if you want/need to change it in Jenkins you have two options:检查你的端口后,如果你想/需要在 Jenkins 中更改它,你有两个选择:

  • by command: java -jar jenkins.war --httpPort=80通过命令: 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修改 Jenkins 配置文件: /PATH/jenkins ,搜索HTTP_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.如果您想使用端口 8080,请确保您在 GCP 中为此端口设置了正确的防火墙规则。 You can use the commands appointed by @J.Rojas.您可以使用@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.如果您在 docker 容器内运行网络应用程序,那么在将其浏览到网络浏览器之前,您需要进行端口映射。

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.这会将您的本地主机映射到容器的内部 IP,您可以轻松访问该应用程序。

To change the port you can do:要更改端口,您可以执行以下操作:

docker run -p 8356:8080 jenkins

It can be accessed on port 8356. Thanks它可以在端口 8356 上访问。谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 Jenkins 将 docker 映像部署到 GKE - Unable to deploy docker image to GKE using Jenkins 无法在 jenkins docker-agent 中使用 gcloud - Unable to use gcloud in a jenkins docker-agent Angular 2 应用程序部署在 AWS 上运行的 docker 容器中 - Angular 2 app deploy in a docker Container running on AWS 将角色传递给运行在 kube.netes 上的 docker 容器 - Pass Role to docker container running on kubernetes 无法使用 Go Docker 引擎 ZDB974238714CA81DE634A7C2Z 的容器在 Docker 中安装文件夹 - Unable to mount a folder in Docker from container with Go Docker Engine API Jenkins Docker 容器无法访问 GKE Autopilot 中的 docker.sock - Jenkins Docker Container can't access docker.sock in GKE Autopilot api 无法将跟踪发送到 docker 容器中的 aws-xray deamon - api unable to send the traces to aws-xray deamon in docker container Jenkins 的 Amazon EC2 插件:错误:无法启动 EC2 代理 - Amazon EC2 Plugin for Jenkins: ERROR: Unable to launch the agent for EC2 将 Go 服务器作为 Docker 容器运行时出现权限被拒绝错误 - Permission denied error when running Go server as Docker container 如何使用 intelliJ 中的 AWS 工具包将文件复制到运行 Lambda 的 docker 容器 - How to copy file to docker container running Lambda with AWS Toolkit in intelliJ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM