jenkins+docker搭建持续集成环境3
从上文配置好docker后,就可以用docker安装gitlab仓库了
#从镜像仓库获取gitlab,这里用的是中文版
[[email protected] ~]# docker pull twang2218/gitlab-ce-zh
Using default tag: latest
latest: Pulling from twang2218/gitlab-ce-zh
8ee29e426c26: Pull complete
6e83b260b73b: Pull complete
e26b65fd1143: Pull complete
40dca07f8222: Pull complete
b420ae9e10b3: Pull complete
a218309dd589: Pull complete
5c60fd7ba0ce: Pull complete
659c2144b5a3: Pull complete
8289bbac0d0e: Pull complete
31bbd150e8a7: Pull complete
9114e78243fa: Pull complete
e242e5cd1314: Pull complete
0a079dc3f92c: Pull complete
f0e195b09fd2: Pull complete
6e23346e2f58: Pull complete
91f00659be69: Pull complete
a1031bcc5b2c: Pull complete
e3074327c7b1: Pull complete
a917618dbe42: Pull complete
Digest: sha256:62686b74c6fca5ece8ed582d03a126c5988423dd8a19ce70e9a22357ffcaf1c8
Status: Downloaded newer image for twang2218/gitlab-ce-zh:latest
docker.io/twang2218/gitlab-ce-zh:latest
[[email protected] ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest 927899a31456 3 days ago 647MB
httpd latest b2c2ab6dcf2e 5 days ago 166MB
twang2218/gitlab-ce-zh latest 18da462b5ff5 21 months ago 1.61GB#运行gitlab,-d 后台运行,-p映射端口,-v把gitlab的配置,日志,数据绑定到本地文件中
[[email protected] ~]# docker run --name gitlab -d -p 8443:443 -p 8090:80 -p 8022:22 --restart always -v /usr/local/gitlab/etc:/etc/gitlab -v /usr/local/gitlab/log:/var/log/gitlab -v /usr/local/gitlab/data:/var/opt/gitlab --privileged=true twang2218/gitlab-ce-zh
e074093b88d8f593972fcbe58d05c3fe546e1f8385e3d6c123abc3763aa4b7ce
[[email protected] ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e074093b88d8 twang2218/gitlab-ce-zh "/assets/wrapper" 4 seconds ago Up 3 seconds (health: starting) 0.0.0.0:8022->22/tcp, 0.0.0.0:8090->80/tcp, 0.0.0.0:8443->443/tcp gitlab
接下来就可以在浏览器输入ip:8090访问gitlab了
出现个问题,项目地址显示的是容器的id
解决办法:
#进入gitlab容器
[[email protected] ~]# docker exec -it gitlab bash
#修改gitlab.rb配置文件,ip和端口根据自己的来设置
[email protected]:/etc/gitlab# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.100.20'
gitlab_rails['gitlab_ssh_host'] = '192.168.100.20'
gitlab_rails['gitlab_shell_ssh_port'] = 8022
#重载配置
[email protected]:/etc/gitlab# gitlab-ctl reconfigure
#修改gitlab.yml,把端口改为映射虚拟机的端口8090
[email protected]:/etc/gitlab# vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 192.168.100.20
port: 8090
https: false#重启服务
[email protected]:/etc/gitlab# gitlab-ctl restart
重新登录gitlab,问题解决