Help us understand the problem. What is going on with this article?

Jenkinsおじさんとdocker

More than 3 years have passed since last update.

はじめに

世の中には多くのCIツールがありますが、自分はJenkinsおじさんとの付き合いが一番長いです。そんなわけで、どこで作業するにもdockerで起動するようになっていれば困らないだろう(少なくとも自分は)と思い、Jenkins用のDockerfileを自作していました。

ただ、自作のため、アップデートなどのDockerfileのメンテが面倒少し手間がかかるので、何かないかなーと探していると、 Official Jenkins Docker image を見つけました。
こちらを利用している方が今後ラクチン汎用性があるのではと思いましたので、起動手順を書いておきます。

環境

  • OS: Ubuntu14.04
  • docker version: 1.4.1

前準備

jenkins_homeの永続化用にディレクトリを用意します。

mkdir jenkins_home
chmod 777 jenkins_home

Jenkinsコンテナ起動

sudo docker run -p 8080:8080 -d \
 -v [PATH]/jenkins_home:/var/jenkins_home \
 jenkins

※[PATH]は適宜修正して下さい。

動作確認

URL
http://(dockerホストのIPアドレス):8080

アクセスすると、Jenkinsが使えますので、プラグイン入れるなり、ジョブを作るなりすればOKです。

補足

使用したイメージのDockerfile

自分が使用したのは、latest, 1.565.3 (Dockerfile)です。
Official Jenkins Docker image

Dockerfile(jenkins)
FROM java:openjdk-7u65-jdk
RUN apt-get update && apt-get install -y wget git curl zip && rm -rf /var/lib/apt/lists/*
ENV JENKINS_VERSION 1.565.3
RUN mkdir /usr/share/jenkins/
RUN useradd -d /home/jenkins -m -s /bin/bash jenkins
COPY init.groovy /tmp/WEB-INF/init.groovy.d/tcp-slave-angent-port.groovy
RUN curl -L http://mirrors.jenkins-ci.org/war-stable/$JENKINS_VERSION/jenkins.war -o /usr/share/jenkins/jenkins.war \
&& cd /tmp && zip -g /usr/share/jenkins/jenkins.war WEB-INF/init.groovy.d/tcp-slave-angent-port.groovy && rm -rf /tmp/WEB-INF
ENV JENKINS_HOME /var/jenkins_home
RUN usermod -m -d "$JENKINS_HOME" jenkins && chown -R jenkins "$JENKINS_HOME"
VOLUME /var/jenkins_home
# for main web interface:
EXPOSE 8080
# will be used by attached slave agents:
EXPOSE 50000
USER jenkins
COPY jenkins.sh /usr/local/bin/jenkins.sh
ENTRYPOINT ["/usr/local/bin/jenkins.sh"]

Java is a concurrent, class-based, and object-oriented programming language.
java:openjdk-7u65-jdkは既にアップデートされていたが、基本構成は同じ

Dockerfile(java
FROM debian:jessie
# A few problems with compiling Java from source:
# 1. Oracle. Licensing prevents us from redistributing the official JDK.
# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets
# really hairy.
ENV JAVA_VERSION 7u71
ENV JAVA_DEBIAN_VERSION 7u71-2.5.3-2
RUN apt-get update && apt-get install -y curl openjdk-7-jdk="$JAVA_DEBIAN_VERSION" unzip wget
# If you're reading this and have any feedback on how this image could be
# improved, please open an issue or a pull request so we can discuss it!
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away