docker-jenkins容器无法访问互联网

问题描述 投票:0回答:1

我在docekr上安装了jenkins容器。

我使用docker-compose和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毫秒

    docker run -it ubuntu:trusty ping google.com
    

    ping:未知主机google.com

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

也许不是由于测试用例3而引起的桥接问题。

我不知道该检查什么。

您能给我一些提示吗?

谢谢!

docker jenkins containers
1个回答
0
投票

您仅在环回接口上公开端口。从[]更改您的端口声明

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

to

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

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

© www.soinside.com 2019 - 2024. All rights reserved.