Docker Gitlab

1.下载GitLab镜像

docker pull gitlab/gitlab-ce默认latest版本

docker pull gitlab/gitlab-ce:rc指定版本

2.查看镜像

docker images

3.启动GitLab镜像

docker run --detach \
  --hostname gitlab \
  --publish 46443:443 --publish 46080:80 --publish 46022: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 \
  --volume /srv/gitlab/logs/reconfigure:/var/log/gitlab/reconfigure \
  gitlab/gitlab-ce:latest
属性 说明
--detach 以守护进程的方式启动
--hostname 设置主机名
--publish a:b 把容器的b端口映射到外部的a端口
--privileged=true 使得容器内部的root拥有真正的root权限,否则只有外部普通用户的权限
--name gitlab 容器的名称,用于启动或停止容器, 查看日志docker logs gitlab
--restart always 一直开启,自动重启,开机自启
--volume dirA:dirB 将容器的dirB路径映射到外部的dirA路径
gitlab/gitlab-ce:latest 需要运行的镜像

4.查看是否运行成功

docker container ls

5.配置GitLab

根据3中的路径,修改其中的/config/gitlab.rb配置文件

    # 配置http协议所用的端口,不加端口号默认为80
    external_url 'http://xxx.xxx.xxx.xxx"
    # 配置ssh协议所使用的访问地址和端口
    gitlab_rails['gitlab_ssh_host'] = 'xxx.xxx.xxx.xxx'
    # 此端口是run是22端口的映射的端口
    gitlab_rails['gitlab_shell_ssh_port'] = 46022

6.应用配置

docker exec gitlab gitlab-ctl reconfigure使用docker的gitlab环境

可使用docker exec -it gitlab bash来进入docker镜像的bash环境

posted @ 2022-04-03 16:32  critipan  阅读(112)  评论(0编辑  收藏  举报