前言:gitlab是git版本控制工具的服务器,而本地使用需要安装git客户端,如elipse和IDEA需要集成git.exe才能使用相关的命令。SourceTree是一个可视化的git客户端操作工具,它可以有效的展示你的文件的变更历史(树形结构)
1、先准备好docker环境
详情见[centos上安装docker]
2、从官方的hub里面拉取gitlab镜像
#docker pull gitlab/gitlab-ce
3、新建并启动容器
[root@LO-O-DEE01 ~]# docker run -d -p 443:443 docker.io/gitlab/gitlab-ce
f4962bb886dbef7593fb788129f2702ed5dec47cbfc0a9719fe490f371bc5e71
出现以上表示启动成功。(这种方式不成功,无法启动)
[root@LO-O-DEE01 ~]
docker run -d \
--privileged=true \
-p 443:443 -p 80:80 -p 2200:22 \
--name gitlab \
--restart always \
-v /home/hzq/gitlab/config:/etc/gitlab \
-v /home/hzq/gitlab/logs:/var/log/gitlab \
-v /home/hzq/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
黑体字换成镜像名字:gitlab/gitlab-ce
查看docker镜像:
[root@LO-O-DEE01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/gitlab/gitlab-ce latest b0c14a03d594 6 days ago 1.48 GB
4、查看启动的docker容器
[root@LO-O-DEE01 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f4962bb886db docker.io/gitlab/gitlab-ce "/assets/wrapper" 52 minutes ago Up 52 minutes (healthy) 22/tcp, 80/tcp, 0.0.0.0:443->443/tcp eager_perlman
变成healthy才启动成功。
访问:http:172.16.5.198:80
先设置密码,然后用root帐号登录
5、停止、删除 docker容器
#docker stop container_id (先停止)
# docker rm container_id(在删除)
6、进入到container里面的轻量级虚拟机
#docker container exec -it f978eadebb95 /bin/bash
【root@f978eadebb95】#
如查看gitlab的版本号:cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
注意:第3条中的命令官网上如下:(非root用户,用sudo)
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
Run GitLab CE on public IP address (GitLab community enterprise)
You can make Docker to use your IP address and forward all traffic to the GitLab CE container by modifying the --publish flag.
To expose GitLab CE on IP 1.1.1.1:
sudo docker run --detach \
--hostname gitlab.example.com \
--publish 1.1.1.1:443:443 \
--publish 1.1.1.1:80:80 \
--publish 1.1.1.1:22:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
####################端口号说明########################
80 (HTTP)
443 (if you configure HTTPS)
8080 (used by Unicorn)
22 (used by the SSH daemon)
Warning: Do NOT use port 8080 otherwise there will be conflicts. This port is already used by Unicorn that runs internally in the container.