docker+docker-compose+gitlab

Docker 安装

下载

下载docker二级制文件docker-20.10.9.tgz

https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz

上传到/data目录

解压文件

cd /data

tar -zxf docker-20.10.9.tgz

移动解压出来的文件到/usr/bin目录

mv docker/* /usr/bin/

创建docker服务

cat > /etc/systemd/system/docker.service <<EOF

Unit

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

Service

Type=notify

the default is not to use systemd for cgroups because the delegate issues still

exists and systemd currently does not support the cgroup feature set required

for containers run by docker

ExecStart=/usr/bin/dockerd --graph /data/docker -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

ExecReload=/bin/kill -s HUP $MAINPID

Having non-zero Limit*s causes performance problems due to accounting overhead

in the kernel. We recommend using cgroups to do container-local accounting.

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

Uncomment TasksMax if your systemd version supports it.

Only systemd 226 and above support this version.

#TasksMax=infinity

TimeoutStartSec=0

set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

kill only the docker process, not all processes in the cgroup

KillMode=process

restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s

Install

WantedBy=multi-user.target

EOF

设置执行权限 并启动docker服务

chmod +x /etc/systemd/system/docker.service

启动服务,并设置开机启动

systemctl daemon-reload && systemctl start docker && systemctl enable docker.service

验证服务器启动

systemctl status docker

安装docker-compose

上传docker-compose-linux-x86_64

配置执行权限

chmod +x docker-compose-linux-x86_64

重命名为docker-compose并移动到/usr/local/bin/目录

mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose

验证

docker-compose -v

部署Gitlab

上传镜像

进入镜像目录,加载docker镜像

cd /data/gitlab/docker-compose/

docker load -I gitlab16.2.0.tar

修改配置文件

使用docker-compose通过yml配置文件启动容器

gitlab.yml文件内容

version: '3.8'

services:

web:

image: 'gitlab/gitlab-ce:16.2.0-ce.0' # 使用GitLab社区版镜像,也可使用gitlab/gitlab-ee:latest(企业版)

restart: always

user: 'root' # 设置容器中运行的用户为root用户

#hostname: 'gitlab' # 替换成你的GitLab主机名

container_name: 'gitlab'

environment:

GITLAB_OMNIBUS_CONFIG: |

external_url 'http://192.168.200.160' # 替换成你的GitLab访问URL

ports:

  • '80:80'

  • '443:443'

  • '2222:22' # 用于SSH访问

volumes:

  • '/data/gitlab/gitlab_home/config:/etc/gitlab'

  • '/data/gitlab/gitlab_home/logs:/var/log/gitlab'

  • '/data/gitlab/gitlab_home/data:/var/opt/gitlab'

privileged: true

启动容器

docker-compose -f gitlab.yml up -d

获取初始密码登录

等待Web界面启动

获取初始化密码

cat /data/gitlab/gitlab_home/config/initial_root_password

登录后的页面

相关推荐
代码羊羊1 小时前
Rust 迭代器完全通俗易懂指南(零基础全覆盖)
java·开发语言·rust
MY_TEUCK8 小时前
【Java 后端】SpringBoot 登录认证与会话跟踪实战(JWT + Filter/Interceptor)
java·开发语言·spring boot
今天长肉了吗8 小时前
银行风控项目踩坑实录:指标跑了6小时,风险评分全挂了
java
随读手机9 小时前
多式联运信息交互平台完整方案(2026版)
java·ai·eclipse·云计算·区块链
许彰午9 小时前
03-二叉树——从递归遍历到非递归实现
java·算法
nj01289 小时前
Spring 循环依赖详解:三级缓存、早期引用、AOP 代理与懒加载
java·spring·缓存
野生技术架构师9 小时前
2026年最全Java面试题及答案汇总(建议收藏,面试前看这篇就够了)
java·开发语言·面试
一只叫煤球的猫10 小时前
ThreadForge 源码解读一:ThreadScope 如何把并发任务放进清晰边界?
java·面试·开源
洛_尘11 小时前
Python 5:使用库
java·前端·python
程序员小假11 小时前
HTTP3 性能更好,为什么内网微服务依然多用 HTTP2?HTTP2 内网优势是什么?
java·后端