Dockerfile
FROM jenkins/jenkins:2.414.2-lts-jdk17
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"
生成镜像
docker build -t jenkins-blueocean:2.414.2-1 .
docker-compose.yaml
version: '3.9'
services:
jenkins-docker:
image: "docker:dind"
container_name: jenkins-docker
restart: always
privileged: true
environment:
- DOCKER_TLS_CERTDIR=/certs
volumes:
- ./jenkins-docker-certs:/certs/client
- ./jenkins-data:/var/jenkins_home
- /lib/modules/:/lib/modules/
ports:
- "2376:2376"
networks:
jenkins:
aliases:
- docker
command: --storage-driver=overlay2
jenkins:
image: "jenkins-blueocean:2.414.2-1"
container_name: jenkins-blueocean
restart: always
environment:
- TZ=Asia/Shanghai
- DOCKER_HOST=tcp://docker:2376
- DOCKER_CERT_PATH=/certs/client
- DOCKER_TLS_VERIFY=1
networks:
- jenkins
ports:
- "8080:8080"
- "50000:50000"
volumes:
- ./jenkins_home:/var/jenkins_home
- ./jenkins-docker-certs:/certs/client:ro
networks:
jenkins:
driver: bridge
运行 jenkins
# docker-compose up -d
[+] Running 3/3
✔ Network jenkins_jenkins Created 0.3s
✔ Container jenkins-blueocean Started 0.8s
✔ Container jenkins-docker Started