Quick Start: Jenkins

Quick Start: Jenkins

Prerequisite

OR

Note: If using 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
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"

DNS Configuration

Configure your DNS or modify your hosts file:

  • For Unix-like systems: Edit /etc/hosts
  • For Windows: Edit C:\Windows\System32\drivers\etc\hosts

Add the following line:

1
127.0.0.1 jenkins.x.internal

Run

1
2
3
4
docker compose up -d
# Alternative commands:
# docker compose -p jenkins up -d
# docker compose -f ./compose.yml -p jenkins up -d

Access: https://jenkins.x.internal