基于 Docker 安装 GitLab 和 GitLab-Runner

安装 docker 并拉取相关镜像

  • gitlab/gitlab-ce

  • gitlab/gitlab-runner

1
2
docker pull gitlab/gitlab-ce
docker pull gitlab/gitlab-runner

运行 docker 镜像

  • GitLab CE
1
2
3
4
5
6
7
8
9
10
docker run -d \
--name gitlab \
--restart always \
-p 127.0.0.1:50080:80 \
-p 127.0.0.1:50022:22 \
-m 2048m \
-v /opt/docker/gitlab/config:/etc/gitlab \
-v /opt/docker/gitlab/logs:/var/log/gitlab \
-v /opt/docker/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
1
2
3
4
5
6
7
8
docker run -d \
--name gitlab-runner \
--link gitlab:gitlab \
--restart always \
-m 1024m \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /opt/docker/gitlab-runner/config:/etc/gitlab-runner \
gitlab/gitlab-runner:latest
  • GitLab EE
1
2
3
4
5
6
7
8
9
10
11
docker run -d \
--name gitlab \
--restart always \
-p 127.0.0.1:50080:80 \
-p 127.0.0.1:50022:22 \
-m 2048m \
-v /opt/docker/gitlab/config:/etc/gitlab \
-v /opt/docker/gitlab/logs:/var/log/gitlab \
-v /opt/docker/gitlab/data:/var/opt/gitlab \
-v /opt/docker/gitlab/.license_encryption_key.pub:/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub \
gitlab/gitlab-ee:latest

注册 gitlab-runner

1
2
3
docker exec -it gitlab-runner gitlab-runner register
# 之后访问地址 http://code.52xckl.cn/admin/runners 配置即可
# 配置地址可以使用 http://gitlab 内网

参考文档

  • gitlab

  • gitlab-runner