[Jenkins][GitLab]docker-compose实现

之前实现了在Docker中运行Jenkins以及[Docker]GitLab使用,参考Docker Compose,通过docker-compose方式同时启动两个容器

docker-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
33
version: "3.7"
services:
jenkins:
labels:
AUTHOR: "zhujian <zjzstu@github.com>"
container_name: jenkins
image: jenkins/jenkins
volumes:
- "jenkins_home:/var/jenkins_home"
ports:
- "7070:8080"
- "50000:50000"
restart: always
tty: true
stdin_open: true
gitlab:
labels:
AUTHOR: "zhujian <zjzstu@github.com>"
container_name: gitlab
image: gitlab/gitlab-ce:latest
volumes:
- "/srv/gitlab/config:/etc/gitlab"
- "/srv/gitlab/logs:/var/log/gitlab"
- "/srv/gitlab/data:/var/opt/gitlab"
ports:
- "7010:7010"
- "7020:22"
restart: always
tty: true
stdin_open: true
volumes:
jenkins_home:
external: true

启动/停止

1
2
3
4
# 启动,后台运行
$ docker-compose up -d
# 停止并移除容器
$ docker-compose down

注意:上述命令需要在docker-compose.yml路径下执行