Krishna. A
Krishna. A

Reputation: 43

docker-jenkins container can't access internet

I installed jenkins container on docekr.

I used docker-compose with yml file.

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

In logs, i found UnknownHostException error.

    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

I tried to resolve this error. But failed finally.

  1. set 'dns' parameter.

    nameserver 8.8.8.8
    nameserver 1.1.1.1
    
  2. reset bridge network.

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

    docker run -it bitnami/jenkins:2 ping 8.8.8.8
    

    [FATAL tini (8)] exec ping failed: No such file or directory

    docker run -it ubuntu:trusty ping 8.8.8.8
    

    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=52 time=31.3 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=52 time=30.8 ms

    docker run -it ubuntu:trusty ping google.com
    

    ping: unknown host google.com

I think bitnami/jenkins maybe doesn't include ping.

Maybe It's not problem about bridge because of Test case 3.

I don't know what should I check.

Can you give me some hints?

Thank you!

Upvotes: 2

Views: 2606

Answers (1)

wmorrell
wmorrell

Reputation: 5307

You are only exposing your ports on loopback interface. Change your ports declaration from

    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'

To allow accessing those ports on all interfaces (i.e. including from outside the host).

Upvotes: 1

Related Questions