创建挂载目录

mkdir /mydata/gitlab-ce/config
mkdir /mydata/gitlab-ce/data
mkdir /mydata/gitlab-ce/logs

文件赋权

chmod 777 -R /mydata/gitlab-ce

docker-compose安装

安装python3
yum -y install epel-release
yum -y install python3-pip
pip3 --version

修改pip源
mkdir /root/.pip
vi /root/.pip/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
安装依赖
pip3 install setuptools-rust
pip install wheel

pip3 install --upgrade pip
python3 --version
pip3 install docker-compose
docker-compose version

 curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
chmod -R 777 docker-compose
docker-compose --version

创建docker-compose.yml

version: '2'
services:
    gitlab:
      container_name: "gitlab"
      image: 'docker.io/gitlab/gitlab-ce:14.4.5-ce.0'
      restart: always
      hostname: '192.168.56.10'
      privileged: true
      environment:
        TZ: 'Asia/Shanghai'
        GITLAB_OMNIBUS_CONFIG: |
          external_url 'http://192.168.56.10:3080'
          gitlab_rails['time_zone'] = 'Asia/Shanghai'
          gitlab_rails['gitlab_shell_ssh_port'] = 3022
          #gitlab_rails['gitlab_ssh_host'] = 'www.gitlab.htyzlc.com'
      ports:
        - '3080:3080'
        - '3443:443'
        - '3022:22'
      volumes:
        - /mydata/gitlab-ce/config:/etc/gitlab
        - /mydata/gitlab-ce/data:/var/opt/gitlab
        - /mydata/gitlab-ce/logs:/var/log/gitlab
      #shm_size: '1024m'

创建并启动容器

docker-compose up -d

查看密码

 cat /mydata/gitlab-ce/config/initial_root_password

Logo

欢迎加入我们的广州开发者社区,与优秀的开发者共同成长!

更多推荐