持续集成 Docker 上运行 Jenkins, 日志中显示已经启动成功,但本地网页无法打开,求解

HowardWu · 2018年11月04日 · 2741 次阅读

docker 上已成功安装了 Jenkins 镜像,并启动成功。
启动命令:docker run -p 8089:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -u 0 --name jk01 jenkins/jenkins:lts
查看日志:docker logs -f jk01
日志截图如下:

ps 状态如下:

网页打开状态:

求各位大神求解。

附言 1  ·  2018年11月04日

自己找到原因了,其他大家不要入坑:
参考帖子:https://www.cnblogs.com/hypnus-ly/p/8683215.html
原因:
The reason you’re having this, is because on Linux, the docker daemon (and your containers) run on the Linux machine itself, so “localhost” is also the host that the container is running on, and the ports are mapped to.

On Windows (and OS X), the docker daemon, and your containers cannot run natively, so only the docker client is running on your Windows machine, but the daemon (and your containers) run in a VirtualBox Virtual Machine, that runs Linux.
因为 docker 是运行在 Linux 上的,在 Windows 中运行 docker,实际上还是在 Windows 下先安装了一个 Linux 环境,然后在这个系统中运行的 docker。也就是说,服务中使用的 localhost 指的是这个 Linux 环境的地址,而不是我们的宿主环境 Windows。
解决办法:
Step1:新找到 Docker 宿主环境 ip: docker-machine ip default
Step2:得到素质环境 ip 后,在浏览器中加上启动映射的端口后即可打开。

共收到 0 条回复 时间 点赞
HowardWu 关闭了讨论 11月04日 18:03
HowardWu 重新开启了讨论 11月04日 18:07
3楼 已删除
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册