Quick Start: Jenkins

Quick Start: Jenkins

Prerequisite

Traefik on HTTP

OR

Traefik on HTTPS

If HTTP, remove the tls: {} in dynamic configuration

Preparation

compose.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
version: Compose specification

services:
jenkins:
image: jenkins/jenkins
container_name: jenkins
privileged: true
user: root
expose:
- 8080
- 50000
restart: always
extra_hosts:
# config for gerrit, sonar, ldap. if no, remove them
- gerrit.x.internal:192.168.91.103
- sonar.x.internal:192.168.91.103
- ldap.x.internal:192.168.91.103
volumes:
- jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
environment:
- TZ=Asia/Shanghai
networks:
- traefik-net

volumes:
jenkins_home:

networks:
traefik-net:
external: true

jenkins.yml in dir dynamic-conf

You should touch jenkins.yml in traefik dir dynamic-conf.

For much more information, please reference the Prerequisite.

1
2
3
4
5
6
7
8
9
10
11
12
13
http:
routers:
jenkins:
rule: "Host(`jenkins.x.internal`)"
service: "jenkins"
tls: { }

services:
jenkins:
loadBalancer:
servers:
- url: "http://jenkins:8080"

Config domain parse

1
echo "127.0.0.1 jenkins.x.internal\n" >> /etc/hosts

Run

1
2
3
docker compose up -d
# docker compose -p jenkins up -d
# docker compose -f ./compose.yml -p jenkins up -d

Access: https://jenkins.x.internal