Reputation: 44371
I am running the jenkins docker image. When starting, it complains that it is not possible to access the internet.
This is how I run it:
docker pull jenkins
mkdir jenkins-shared-volume
docker run -d -p 49001:8080 -p 50000:50000 -v jenkins-shared-volume:/var/jenkins_home -t --name jenkins jenkins
The jenkins instance is then running on http://localhost:49001. But it has connectivity issues:
Offline This Jenkins instance appears to be offline.
For information about installing Jenkins without an internet connection, see the Offline Jenkins Installation Documentation.
You may choose to continue by configuring a proxy or skipping plugin installation.
I have no proxy in my system (home laptop). I guess this is probably an obscure docker problem but:
Am I doing something wrong?
Just to make sure that indeed the docker container has direct access to the internet:
docker exec -it jenkins /bin/bash
jenkins@4ef4944a7cb7:/$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=44 time=29.859 ms
Running the container connected to the host
network solves the problem and lets jenkins access the internet:
docker run -d --net host -v jenkins-shared-volume:/var/jenkins_home -t --name jenkins jenkins
But I can not map ports: jenkins is directly reachable on http://localhost:8080, which can be a source of conflicts whenever other services are using the 8080 port.
Upvotes: 21
Views: 14521
Reputation: 207
I had the same error while running nginx & jenkins.Turned out to be a dns issue. I use docker-compose and resolved it by adding dns into the jenkins yaml.
example:
---
version: "2.3"
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins:lts
restart: unless-stopped
ports:
- "8080:8080"
- "50000:50000"
volumes:
- "./jenkins/jenkins_home:/var/jenkins_home"
extra_hosts:
- "host.docker.internal:host-gateway"
dns:
- 8.8.8.8
- 4.4.4.4
- host.docker.internal
Upvotes: 0
Reputation: 151
When you run 'ping 8.8.8.8', you are testing internet connection but not DNS resolution.
Try 'ping www.google.com', I think you are having a DNS issue, thats why Jenkins can't reach the plugins packages.
Edit /etc/docker/daemon.json and set your local DNS servers to avoid Docker using default Google Public DNS. Docker Docs - Daemon configuration file .
Upvotes: 2
Reputation: 833
Strangely I ran into the same issue last night using the official Jenkins image:
docker run -p 8080:8080 --rm jenkins/jenkins
Though I have not figured out why yet or how to permanently fix it, I did find a work around.
Launch the image with the older un-supported image jenkins... do the initial setup.. then shut it down, swap the image and startup the official.
For reference here is my docker-compose.yml:
version: "2"
services:
app:
image: jenkins #after booting and initial setup swap to jenkins/jenkins
ports:
- "50000:50000"
- "8080:8080"
volumes:
- home:/var/jenkins_home
volumes:
home:
Upvotes: 2