一、查找Gitlab镜像
[root@staging ~]# docker search gitlab
二、拉取Gitlab镜像
[root@staging ~]# docker pull gitlab/gitlab-ce:latest
三、运行GitLab
[root@staging ~]# docker run \
-itd \
-p 9443:443 \
-p 9980:80 \
-p 9922:22 \
-v /usr/local/gitlab-test/etc:/etc/gitlab \
-v /usr/local/gitlab-test/log:/var/log/gitlab \
-v /usr/local/gitlab-test/opt:/var/opt/gitlab \
--restart always \
--privileged=true \
--name gitlab \
gitlab/gitlab-ce:latest
四、验证GitLab容器
[root@staging ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b491ceabf5e gitlab/gitlab-ce:latest "/assets/wrapper" 45 minutes ago Up 6 minutes (unhealthy) 0.0.0.0:9922->22/tcp, 0.0.0.0:9980->80/tcp, 0.0.0.0:9443->443/tcp gitlab
五、修改管理员密码
#1.进入容器
[root@staging ~]# docker exec -it gitlab bash
#2.修改root密码
root@3b491ceabf5e:/etc/gitlab# gitlab-rake "gitlab:password:reset[root]"
Enter password:
Confirm password:
Password successfully updated for user with username root.
六、测试登录
输入IP+Port,本机192.168.2.18:9980,输入正确的用户名和修改过后的密码即可正常登陆。