Dockerfile source for Jenkins docker image.
This source repo was originally copied from: https://github.com/jenkinsci/docker
This is not an official Google product.
This image contains an installation of Jenkins 2.x.
For more information, visit the Marketplace page for Jenkins.
Pull command (first install gcloud):
gcloud docker -- pull marketplace.gcr.io/google/jenkins2
The Dockerfile for this image can be found here.
For additional information about setting up your Kubernetes environment, consult the official Google Cloud Marketplace documentation.
This section describes how to spin up a Jenkins service using this image.
Copy the following content to the file pod.yaml
, and run kubectl create -f pod.yaml
.
apiVersion: v1
kind: Pod
metadata:
name: some-jenkins
labels:
name: some-jenkins
spec:
containers:
- image: marketplace.gcr.io/google/jenkins2
name: jenkins
To expose the ports, run the following commands.
Depending on your cluster setup, this might expose your service to the Internet with an external IP address. For more information, consult the Kubernetes documentation.
kubectl expose pod some-jenkins --name some-jenkins-8080 \
--type LoadBalancer --port 8080 --protocol TCP
kubectl expose pod some-jenkins --name some-jenkins-50000 \
--type LoadBalancer --port 50000 --protocol TCP
To retain Jenkins data across container restarts, see Adding persistence.
See Configurations for how to customize your Jenkins service instance.
To log in for the first time, view the generated administrator password.
kubectl exec some-jenkins -- cat /var/jenkins_home/secrets/initialAdminPassword
To pass JVM arguments, use the environment variable JAVA_OPTS
. For example,
the following commands increase the size of the heap to 2G and the size of
PermGen to 128M:
Copy the following content to the pod.yaml
file, and run
kubectl create -f pod.yaml
:
apiVersion: v1
kind: Pod
metadata:
name: some-jenkins
labels:
name: some-jenkins
spec:
containers:
- image: marketplace.gcr.io/google/jenkins2
name: jenkins
env:
- name: "JAVA_OPTS"
value: "-Xmx2G -XX:MaxPermSize=128m"
To expose the ports, run the following commands:
Depending on your cluster setup, this might expose your service to the Internet with an external IP address. For more information, consult the Kubernetes documentation.
kubectl expose pod some-jenkins --name some-jenkins-8080 \
--type LoadBalancer --port 8080 --protocol TCP
kubectl expose pod some-jenkins --name some-jenkins-50000 \
--type LoadBalancer --port 50000 --protocol TCP
To back up your data, copy the directory /var/jenkins_home
on the container
to the directory /path/to/your/jenkins/home
on your host:
kubectl cp some-jenkins:/var/jenkins_home /path/to/your/jenkins/home
For additional information about setting up your Docker environment, visit the official Google Cloud Marketplace documentation.
This section describes how to use this image to spin up a Jenkins service.
Use the following content for your docker-compose.yml
file, then run
docker-compose up
:
version: '2'
services:
jenkins:
container_name: some-jenkins
image: marketplace.gcr.io/google/jenkins2
ports:
- '8080:8080'
- '50000:50000'
You can also use docker run
directly:
docker run \
--name some-jenkins \
-p 8080:8080 \
-p 50000:50000 \
-d \
marketplace.gcr.io/google/jenkins2
Your Jenkins server is accessible on port 8080.
To retain Jenkins data across container restarts, refer to Adding persistence.
For information about how to customize your Jenkins service instance, refer to Configurations.
All Jenkins data is stored in /var/jenkins_home
, including plugins and
configurations. To ensure that this data persists when the container
is restarted, this directory should be mounted on a persistent volume.
Assume that /path/to/jenkins/home
is the persistent directory on your
host.
Use the following content for the docker-compose.yml
file, then run docker-compose up
.
version: '2'
services:
jenkins:
container_name: some-jenkins
image: marketplace.gcr.io/google/jenkins2
ports:
- '8080:8080'
- '50000:50000'
volumes:
- /path/to/jenkins/home:/var/jenkins_home
You can also use docker run
:
docker run \
--name some-jenkins \
-p 8080:8080 \
-p 50000:50000 \
-v /path/to/jenkins/home:/var/jenkins_home \
-d \
marketplace.gcr.io/google/jenkins2
To log in for the first time, view the generated administrator password:
docker exec some-jenkins cat /var/jenkins_home/secrets/initialAdminPassword
You can pass JVM arguments by using the environment variable JAVA_OPTS
.
For example, the following commands increase the size of the heap to 2G and
the size of PermGen to 128M:
Use the following content for the docker-compose.yml
file, then run docker-compose up
.
version: '2'
services:
jenkins:
container_name: some-jenkins
image: marketplace.gcr.io/google/jenkins2
environment:
"JAVA_OPTS": "-Xmx2G -XX:MaxPermSize=128m"
ports:
- '8080:8080'
- '50000:50000'
You can also use docker run
directly:
docker run \
--name some-jenkins \
-e "JAVA_OPTS=-Xmx2G -XX:MaxPermSize=128m" \
-p 8080:8080 \
-p 50000:50000 \
-d \
marketplace.gcr.io/google/jenkins2
To back up your data, copy the directory /var/jenkins_home
on the container
to the directory /path/to/your/jenkins/home
on your host:
docker cp some-jenkins:/var/jenkins_home /path/to/your/jenkins/home
These are the ports exposed by the container image:
Port | Description |
---|---|
TCP 8080 | Jenkins console port. |
TCP 50000 | Replica agent communication port. |
These are the filesystem paths used by the container image:
Path | Description |
---|---|
/var/jenkins_home | Stores all of Jenkins plugins and configurations. |