Docker-Jenkins 容器无法访问互联网



我在docekr上安装了jenkins容器。

我用了docker编写yml文件。

version: '2'
services:
jenkins:
image: 'bitnami/jenkins:2'
ports:
- '8080:8080'
- '8443:8443'
- '50000:50000'
volumes:
- 'jenkins_data:/bitnami/jenkins'
dns:
- '8.8.8.8'
- '1.1.1.1'
volumes:
jenkins_data:
driver: local

在日志中,我发现UnknownHostException错误。

jenkins_1  | 2020-03-23 17:45:06.490+0000 [id=46]       INFO    hudson.util.Retrier#start: The attempt #1 to do the action check updates server failed with an allowed exception:
jenkins_1  | java.net.UnknownHostException: updates.jenkins.io
...
jenkins_1  | 2020-03-23 17:45:06.490+0000 [id=46]       INFO    hudson.util.Retrier#start: Calling the listener of the allowed exception 'updates.jenkins.io' at the attempt #1 to do the action check updates server
jenkins_1  | 2020-03-23 17:45:06.492+0000 [id=46]       INFO    hudson.util.Retrier#start: Attempted the action check updates server for 1 time(s) with no success

我试图解决这个错误。但最终失败了。

  1. 设置"dns"参数。

    nameserver 8.8.8.8
    nameserver 1.1.1.1
    
  2. 重置网桥网络。

    systemctl stop docker
    iptables -t nat -F
    ifconfig docker0 down
    brctl delbr docker0
    systemctl start docker
    
  3. 测试ping

    docker run -it bitnami/jenkins:2 ping 8.8.8.8
    

    〔FATAL tini(8(〕执行ping失败:没有这样的文件或目录

    docker run -it ubuntu:trusty ping 8.8.8.8
    

    PING 8.8.8.8(8.8.8.8(56(84(字节的数据。8.8.8.8中的64个字节:icmp_seq=1 ttl=52时间=31.3 ms来自8.8.8.8的64字节:icmp_seq=2ttl=52时间=30.8 ms

    docker run -it ubuntu:trusty ping google.com
    

    ping:未知主机google.com

我认为bitnami/jenkins可能不包括ping。

也许由于测试用例3,桥接器没有问题。

我不知道该查什么。

你能给我一些提示吗?

谢谢!

您只是在环回接口上暴露您的端口。从更改您的港口申报

ports:
- '8080:8080'
- '8443:8443'
- '50000:50000'

ports:
- '0.0.0.0:8080:8080'
- '0.0.0.0:8443:8443'
- '0.0.0.0:50000:50000'

允许访问所有接口上的这些端口(即,包括从主机外部访问(。

最新更新