参考:
https://docs.gitlab.com/omnibus/docker/README.html
利用GitLab Docker images安装GitLab(填坑)
下面是我的步骤:
1、下载gitlab-ce:
docker pull gitlab/gitlab-ce
2、启动脚本
#!/bin/bash sudo docker run --detach --hostname gitlab.example.com --publish 192.168.1.100:10443:443 --publish 192.168.1.100:10080:10080 --publish 192.168.1.100:10022:22 --name gitlab --restart always --volume /gitlab/gitlab_data/config:/etc/gitlab --volume /gitlab/gitlab_data/logs:/var/log/gitlab --volume /gitlab/gitlab_data/data:/var/opt/gitlab gitlab/gitlab-ce:latest
上面的192.168.1.100是我的电脑的IP地址,/gitlab/gitlab_data/config、/gitlab/gitlab_data/logs以及/gitlab/gitlab_data/data三个目录要先提前建好
3、运行脚本
4、修改gitlab.rb
vim /gitlab/gitlab_data/config/gitlab.rb:
external_url 'http://192.168.1.100:10080' gitlab_rails['gitlab_shell_ssh_port'] = 10022
或者使用下面的命令修改:
sudo docker exec -it gitlab /bin/bash
vim /etc/gitlab/gitlab.rb
4、重启gitlab
docker restart gitlab
然后使用docker ps查看gitlab容器的状态,当从health: starting变成healthy后,就可以使用浏览器登录了:
c85f6495d915 gitlab/gitlab-ce:latest "/assets/wrapper" 10 minutes ago Up 2 seconds (health: starting) 80/tcp, 192.168.1.100:10080->10080/tcp, 192.168.1.100:10022->22/tcp, 192.168.1.100:10443->443/tcp gitlab
c85f6495d915 gitlab/gitlab-ce:latest "/assets/wrapper" 12 minutes ago Up About a minute (healthy) 80/tcp, 192.168.1.100:10080->10080/tcp, 192.168.1.100:10022->22/tcp, 192.168.1.100:10443->443/tcp gitlab
如果一直处在starting的话,可以先看看/gitlab/gitlab_data/logs/reconfigure/下面的log,定位一下问题。如果还是无法解决,可以将容器和镜像删除,然后重新导入镜像,再创建容器
5、访问
6、为了以后安装方便,可以将这个镜像导出到本地
docker save -o gitlab-ce.tar gitlab/gitlab-ce:latest
完