Code Monkey home page Code Monkey logo

jenkins-docker's Introduction

jenkins-docker

Dockerfile source for Jenkins docker image.

Upstream

This source repo was originally copied from: https://github.com/jenkinsci/docker

Disclaimer

This is not an official Google product.

About

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.

Table of Contents

Using Kubernetes

For additional information about setting up your Kubernetes environment, consult the official Google Cloud Marketplace documentation.

Running your Jenkins server

This section describes how to spin up a Jenkins service using this image.

Starting a Jenkins instance

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.

Configurations

Logging in for the first time

To log in for the first time, view the generated administrator password.

kubectl exec some-jenkins -- cat /var/jenkins_home/secrets/initialAdminPassword

Passing JVM arguments

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

Maintaining your deployment

Creating a Jenkins backup

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

Using Docker

For additional information about setting up your Docker environment, visit the official Google Cloud Marketplace documentation.

Running your Jenkins server

This section describes how to use this image to spin up a Jenkins service.

Starting a Jenkins instance

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.

Adding persistence

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

Configurations

Logging in for the first time

To log in for the first time, view the generated administrator password:

docker exec some-jenkins cat /var/jenkins_home/secrets/initialAdminPassword

Passing JVM arguments

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

Maintaining your Jenkins deployment

Creating a Jenkins backup

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

References

Ports

These are the ports exposed by the container image:

Port Description
TCP 8080 Jenkins console port.
TCP 50000 Replica agent communication port.

Volumes

These are the filesystem paths used by the container image:

Path Description
/var/jenkins_home Stores all of Jenkins plugins and configurations.

jenkins-docker's People

Contributors

aav66 avatar adrianmaniek avatar armandomiani avatar axtnsx avatar eugenekorolevich avatar farajn9 avatar geofrau avatar harnas-google avatar huyhg avatar jprzychodzen avatar khajduczenia avatar marzinkievitz avatar metaver5o avatar ovk6 avatar tomasz-safuryn avatar wgrzelak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.