搭建gitlab
搭建gitlab首先需要一个gitlab的镜像

其次最好为他设置一个单独的目录

然后编写一个docker-compose文件

version: '3.1'
services:
gitlab:
image: 'gitlab_zh:latest' //此处为你的镜像名称
container_name: gitlab //容器名称
restart: always //开机自启动
environment:
GITLAB_OMNIBUS_CONFIG:
external_url 'http://192.168.88.6:8929' //此出应该为虚拟机IP地址
gitlab_rails['gitlab_shell_ssh_port'] = 2224
ports: //占用的端口
- '8929:8929'
- '2224:2224'
volumes: //创建的挂载数据卷
- './config:/etc/gitlab'
- './logs:/var/log/gitlab'
- './data:/var/opt/gitlab'
然后保存退出在此文件的目录下使用以下命令、
docker compose up -d
gitlab容器就已经起来了

然后再浏览器访问IP地址加端口

搭建jenkins
首先要有一个jenkins镜像

最好也需要为他设置一个单独的目录

编辑一个docker-compose文件

version: "3.1"
services:
jenkins:
image: jenkins/jenkins:2.426.2-lts //你的镜像名称
container_name: jenkins //容器名称
ports:
- 8080:8080
- 50000:50000
volumes:
- ./data/:/var/jenkins_home/

然后输入以下命令
docker compose up -d

编排完成后ls查看一下当前文件夹

给data目录权限
chmod -R 777 data
权限给好后然后启动容器
docker start jenkins

使用浏览器访问IP地址加端口访问

密码可以使用命令查看
docker logs -f jenkins
进入可以创建用户来设置自己的用户
进入之后要安装插件一般安装不下来先跳过


进入后点击管理Jenkins创建用户


用户名和密码根据自己设置

用户创建完成
再次登录即可使用root用户登录