1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Jenkinsを起動するDocker Composeがこちらです

Posted at

今日わかったこと

  • Docker HubのOfficial ImageのJenkinsはDEPRECATED。代わりにjenkins/jenkins:ltsを使ってねとのこと
  • 公式サイトには以下の記載あり。

The recommended Docker image to use is the Official jenkins/jenkins image (from the Docker Hub repository). This image contains the current Long-Term Support (LTS) release of Jenkins (which is production-ready). However this image doesn’t have docker CLI inside it and is not bundled with frequently used Blue Ocean plugins and features. This means that if you want to use the full power of Jenkins and Docker you may want to go through described below installation process.

DeepL翻訳

使用する推奨Dockerイメージは、Official jenkins/jenkinsイメージ(Docker Hubリポジトリより)です。このイメージには、Jenkinsの現在のLong-Term Support(LTS)リリースが含まれています(これは本番環境に対応しています)。しかし、このイメージにはdocker CLIが内蔵されておらず、頻繁に使用されるブルーオーシャンのプラグインや機能がバンドルされていません。つまり、JenkinsとDockerのパワーをフルに使いたい場合は、以下のようなインストール手順を踏むことになるでしょう。

JenkinsとDockerのパワーをフルに使う方法をDocker Composeで試したので、その時のログを残します。

作業ログ

console
mkdir ~/jenkins-docker
cd ~/jenkins-docker/
~/jenkins-docker/Dockerfile
FROM jenkins/jenkins:2.303.2-jdk11
USER root
RUN apt-get update && apt-get install -y apt-transport-https \
       ca-certificates curl gnupg2 \
       software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN apt-key fingerprint 0EBFCD88
RUN add-apt-repository \
       "deb [arch=arm64] https://download.docker.com/linux/debian \
       $(lsb_release -cs) stable"
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean:1.25.0 docker-workflow:1.26"

※注:Raspberry Pi 4で試したので[arch=arm64]になってますが、多くの場合は[arch=amd4]だと思います。

~/jenkins-docker/docker-compose.yaml
version: '3.9'

services:
  docker:
    image: docker:dind
    privileged: true
    networks: 
      - jenkins-network
    environment:
      DOCKER_TLS_CERTDIR: /certs
    volumes:
      - ./jenkins-docker-certs:/certs/client
      - ./jenkins-data:/var/jenkins_home
    expose:
      - "2376"

  jenkins-blueocean:
    build: .
    depends_on:
      - docker
    networks: 
      - jenkins-network
    environment:
      DOCKER_HOST: "tcp://docker:2376"
      DOCKER_CERT_PATH: /certs/client
      DOCKER_TLS_VERIFY: 1
    expose:
      - "8080"
      - "50000"
    ports:
      - "8080:8080"
      - "50000:50000"
    volumes:
      - ./jenkins-docker-certs:/certs/client:ro
      - ./jenkins-data:/var/jenkins_home

networks:
  jenkins-network:
    driver: bridge
console
mkdir jenkins-data
mkdir jenkins-docker-certs
docker compose up -d

しばらくすると、Jenkinsが起動し、8080ポートで接続できます。

192.168.0.13_8080_login_from=%2F(iPad).png

Administrator passwordはログに出ているので、docker compose logsで確認しましょう。

あとはこんな感じです。

192.168.0.13_8080_(iPad).png

192.168.0.13_8080_(iPad) (1).png

192.168.0.13_8080_(iPad) (2).png

192.168.0.13_8080_(iPad) (3).png

192.168.0.13_8080_(iPad) (4).png

192.168.0.13_8080_(iPad) (5).png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?