欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 幼教 > Docker 搭建GitLab

Docker 搭建GitLab

2024/10/24 6:36:25 来源:https://blog.csdn.net/qq_40058321/article/details/140663483  浏览:    关键词:Docker 搭建GitLab

# 拉取镜像

docker pull gitlab/gitlab-ce

# GitLab 需要持久存储来保存数据,如仓库数据、配置

mkdir -p /opt/gitlab/config /opt/gitlab/logs /opt/gitlab/data

# 使用 docker run 命令来启动 GitLab 容器

docker run -itd \--hostname 192.168.111.128 \--publish 443:443 \--publish 80:80 \--publish 2222:22 \--name gitlab \--restart always \--volume /opt/gitlab/config:/etc/gitlab \--volume /opt/gitlab/logs:/var/log/gitlab \--volume /opt/gitlab/data:/var/opt/gitlab \gitlab/gitlab-ce:latest

# 解释命令参数说明:
--detach: 让容器在后台运行(-itd 是 -it -d 的结合,--detach = -d)。
--hostname your-gitlab-hostname: 替换为你的 GitLab 主机名或域名。
--publish 443:443 --publish 80:80 --publish 22:22: 将容器内部的 443(HTTPS)、80(HTTP)和 22(SSH)端口映射到主机的对应端口,允许外部访问 GitLab。
--name gitlab: 指定容器的名称为 gitlab。
--restart always: 容器在退出后始终自动重启。
--volume /opt/gitlab/config:/etc/gitlab: 将主机上的 /opt/gitlab/config 目录挂载到容器内的 /etc/gitlab,用于存储 GitLab 的配置文件。
--volume /opt/gitlab/logs:/var/log/gitlab: 将主机上的 /opt/gitlab/logs 目录挂载到容器内的 /var/log/gitlab,用于存储 GitLab 的日志文件。
--volume /opt/gitlab/data:/var/opt/gitlab: 将主机上的 /opt/gitlab/data 目录挂载到容器内的 /var/opt/gitlab,用于存储 GitLab 的数据(如仓库数据、上传文件等)。
 

# 启动时间比较久,耐心等3-5分钟,此时可以查看启动日志
# Docker 容器日志查看

docker logs gitlab

# 如果你访问的页面没提示设置root管理员的密码,需要自己修改
# 修改密码步骤:

# 进入 GitLab 容器或服务器(gitlab_container_name 容器ID)docker exec -it <gitlab_container_name> /bin/bash# 重置管理员密码gitlab-rails console -e production# 在控制台中重置密码user = User.where(id: 1).firstuser.password = 'chengdong'user.password_confirmation = 'chengdong'user.save!# exit 退出控制台并重启 GitLabgitlab-ctl restart

# 登录成功之后设置 中文
# 中间显示 Configure GitLab ==> Settings ==> Preferences ==> Localization 或者上面直接搜索:Default language    root账户只能英文,创建新的账户登录就是中文了

# 修改gitlab的下载代码的路径地址,修改gitlab主配置文件
#/opt/gitlab/config/gitlab.rb
修改:
external_url 'http://192.168.111.128'

# 重启容器

docker restart gitlab

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com