Giter Club home page Giter Club logo

jenkins's Introduction

Jenkins CI with disposable containers

layers

This is a Jenkins CI Server image suitable for running CD work-flows inside disposable containers using Jenkins Docker Pipeline and the Docker daemon present on the host system. Note that this is not a "Docker in Docker" Jenkins setup. This image requires the Docker socket to be mounted inside the Jenkins container. All the Docker commands issued by the Jenkins Docker Pipeline will be executed on the host system. This image also has Ansible installed to facilitate container orchestration over SSH.

This image is based on the official Jenkins image. Each time the official image is updated, Docker Hub will automatically trigger a rebuild of this image.

Running Jenkins

First, you will need to set up persistent storage for Jenkins and the Ansible inventory.

You will need a directory for each on the host, and you will need to give the jenkins user (UID 1000) ownership of both.

For Jenkins:

JENKINS_HOME=/home/$(whoami)/jenkins_home
mkdir $JENKINS_HOME
chown -R 1000 $JENKINS_HOME

For Ansible:

ANSIBLE_INVENTORY=/home/$(whoami)/ansible
mkdir $ANSIBLE_INVENTORY
chown -R 1000 $ANSIBLE_INVENTORY

Run Jenkins container by mounting the Docker socket, jenkins_home and ansible directory:

docker run -d --name jenkins \ 
	-p 8080:8080 -p 50000:50000 \ 
	-v /var/run/docker.sock:/var/run/docker.sock \ 
	-v /home/$(whoami)/jenkins_home:/var/jenkins_home \ 
	-v /home/$(whoami)/ansible:/etc/ansible \ 
	stefanprodan/jenkins

After starting the container, you can access Jenkins at http://localhost:8080. Look in the logs for the admin password that Jenkins is generating on first run:

docker logs jenkins

or run

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

After login, chose Select plugins to install and uncheck all.

Jenkins plugins

Pre-installed plugins:

  • Ant
  • Ansible
  • Build Timeout
  • GitHub
  • Gradle
  • Pipeline
  • Purge Job History
  • CloudBees Docker Pipeline
  • Credentials Binding
  • Simple Theme Plugin
  • SSH Agent
  • SSH Slaves
  • Timestamper
  • Workspace Cleanup
  • Xunit

jenkins's People

Contributors

radu-porumb avatar stefanprodan avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jenkins's Issues

Cannot connect to the Docker daemon

Hi,

I ran your docker container this way

docker run --net=isolated_nw
-e DOCKER_API_VERSION='1.23'
-p 88:8080 -p 50000:50000
-v /var/run/docker.sock:/var/run/docker.sock
-v /volumes/jenkins/jenkins_home:/var/jenkins_home
-v /volumes/jenkins/ansible_inventory:/etc/ansible
--hostname=jenkins --name jenkins
-d stefanprodan/jenkins

As my docker version is Docker version 1.11.2, build bac3bae and running on CoreOS stable, i checked there https://docs.docker.com/engine/reference/api/docker_remote_api/ and have guessed i should specify '1.23' for the environment variable DOCKER_API_VERSION.

When running the build job from the Pipeline sample you provide by your groovy script, i can see this in the Console Output

Started by user admin
[Pipeline] node
Running on master in /var/jenkins_home/workspace/Test pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (aspnetcore)
[Pipeline] sh
[Test pipeline] Running shell script

  • docker inspect -f . microsoft/aspnetcore-build

Cannot connect to the Docker daemon. Is the docker daemon running on this host?
[Pipeline] sh
[Test pipeline] Running shell script

  • docker pull microsoft/aspnetcore-build
    Using default tag: latest
    Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
    Cannot connect to the Docker daemon. Is the docker daemon running on this host?
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline
    ERROR: script returned exit code 1
    Finished: FAILURE

I'm getting nothing relevant using docker logs jenkins.

I can assure you that /var/run/docker.sock is a valid path as the ls -lah /var/run/d* command returns me this

-rw-r--r--. 1 root root 4 Nov 4 20:05 /var/run/docker.pid
srw-rw----. 1 docker docker 0 Nov 4 20:05 /var/run/docker.sock

So i guess CoreOS is not different enough from other systems to cause the issue, don't you think ?
Moreover there's this ls -lah /var/run/d* command result executed in the precedently ran container ( passed thanks to this command docker exec -it jenkins /bin/bash)

srw-rw----. 1 233 233 0 Nov 4 20:05 /var/run/docker.sock
The user or group "233" are unknown (can't see anything like that when i cat /etc/passwd or cat /etc/group, no need to copy their content here i think).

docker -v displays Docker version 1.12.3, build 6b644ec from within the container

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.