一、启动容器

创建目录

mkdir -p /home/qiang/docker-compose/gitlab
vim /home/qiang/docker-compose/gitlab/docker-compose.yaml

docker-compose.yaml

version: '3'
services:
  gitlab:
    restart: always
    image: gitlab/gitlab-ee:latest
    container_name: gitlab
    privileged: true
    ports:
      - '80:80'
      - '443:443'
      - '2222:22'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://192.168.17.101/gitlab'
        gitlab_rails['gitlab_shell_ssh_port'] = 2222
    volumes:
      - /home/qiang/data/gitlab/etc:/etc/gitlab
      - /home/qiang/data/gitlab/opt:/var/opt/gitlab
      - /home/qiang/data/gitlab/log:/var/log/gitlab

img

启动命令

cd /home/qiang/docker-compose/gitlab
docker-compose up -d && docker-compose logs -f

访问地址

http://192.168.17.101/gitlab/

image-20220414152646838

二、账号密码

账号:root
密码:cat /home/qiang/data/gitlab/etc/initial_root_password

三、克隆项目

配置公钥

ssh-keygen
cat /root/.ssh/id_rsa.pub

输入账号密码克隆

git clone http://192.168.17.101/gitlab/gitlab-instance-2ecd6df5/Monitoring.git

四、常见报错

4.1 网络错误

问题:

WARNING: IPv4 forwarding is disabled. Networking will not work.

解决:

echo net.ipv4.ip_forward=1 >> /usr/lib/sysctl.d/00-system.conf
systemctl restart network && systemctl restart network

4.2 启动报错

问题:

服务启动报502错误页面

解决:

运行内存最低要求2G,低于内存容量会报502错误页面