参考:https://docs.gitlab.com/ee/install/docker.html

1 Set up the volumes location 设置存储位置

Before setting everything else, configure a new environment variable $GITLAB_HOME pointing to the directory where the configuration, logs, and data files will reside. Ensure that the directory exists and appropriate permission have been granted.
For Linux users, set the path to /srv/gitlab:

  1. export GITLAB_HOME=/srv/gitlab

For macOS users, use the user’s $HOME/gitlab directory:

  1. export GITLAB_HOME=$HOME/gitlab

The GitLab container uses host mounted volumes to store persistent data:

Local location Container location Usage
$GITLAB_HOME/data /var/opt/gitlab For storing application data.
$GITLAB_HOME/logs /var/log/gitlab For storing logs.
$GITLAB_HOME/config /etc/gitlab For storing the GitLab configuration files.

本次是 wsl 的 ubuntu 20

  1. export GITLAB_HOME=/srv/gitlab

2 安装

可以使用 docker、docker-compose 或者其它,本次选择 docker 和 docker-compose

2.1 docker 形式安装

  1. docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab --restart always --volume $GITLAB_HOME/config:/etc/gitlab --volume $GITLAB_HOME/logs:/var/log/gitlab --volume $GITLAB_HOME/data:/var/opt/gitlab --shm-size 256m gitlab/gitlab-ce:latest

访问地址:http://localhost
image.png

2.1.1 root 密码查看 docker exec -it containerID grep ‘Password:’ /etc/gitlab/initial_root_password

  1. xiaohui@220200700182:/mnt/c/Users/DELL$ docker ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. e4a364266172 gitlab/gitlab-ce:latest "/assets/wrapper" 4 minutes ago Up 4 minutes (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp gitlab
  4. bc46115d86f4 sonarqube:8.9-community "bin/run.sh bin/sona…" 4 hours ago Up 3 hours 0.0.0.0:9000->9000/tcp dell_sonarqube_1
  5. d204d114a190 postgres:12 "docker-entrypoint.s…" 4 hours ago Up 3 hours 0.0.0.0:5432->5432/tcp dell_db_1
  6. 1b807dac92cd liferay/portal:7.4.3.8-ga8 "/usr/local/bin/life…" 9 hours ago Up 9 hours (healthy) 8000/tcp, 8009/tcp, 11311/tcp, 0.0.0.0:8080->8080/tcp optimistic_swartz
  7. 543583525fab nacos/nacos-server:2.0.3 "bin/docker-startup.…" 5 months ago Up 10 hours 0.0.0.0:8848->8848/tcp, 0.0.0.0:9555->9555/tcp, 0.0.0.0:9848->9848/tcp nacos-standalone-mysql
  8. 181d6e2fc256 nacos/nacos-mysql:8.0.16 "docker-entrypoint.s…" 5 months ago Up 8 hours
  9. 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
  10. xiaohui@220200700182:/mnt/c/Users/DELL$
  11. xiaohui@220200700182:/mnt/c/Users/DELL$
  12. xiaohui@220200700182:/mnt/c/Users/DELL$ docker exec -it e4a364266172 grep 'Password:' /etc/gitlab/initial_root_password
  13. Password: O6A1eP/1Nq6CW4wZmWqUHJOs7hPpH2BRhRVI52+Zlk4=
  14. xiaohui@220200700182:/mnt/c/Users/DELL$

2.2 docker-compose 形式安装

  1. version: '3.6'
  2. services:
  3. web:
  4. image: 'gitlab/gitlab-ce:latest'
  5. restart: always
  6. hostname: 'gitlab.my.com'
  7. environment:
  8. GITLAB_OMNIBUS_CONFIG: |
  9. external_url 'http://192.168.0.187'
  10. gitlab_rails['gitlab_shell_ssh_port'] = 22
  11. ports:
  12. - '80:80'
  13. - '443:443'
  14. - '22:22'
  15. volumes:
  16. - '/config:/etc/gitlab'
  17. - '/logs:/var/log/gitlab'
  18. - '/data:/var/opt/gitlab'
  19. shm_size: '256m'

或者使用 gitlab-ee

  1. version: '3.6'
  2. services:
  3. web:
  4. image: 'gitlab/gitlab-ee:latest'
  5. restart: always
  6. hostname: 'gitlab.my.com'
  7. environment:
  8. GITLAB_OMNIBUS_CONFIG: |
  9. external_url 'http://192.168.0.187'
  10. gitlab_rails['gitlab_shell_ssh_port'] = 22
  11. ports:
  12. - '80:80'
  13. - '443:443'
  14. - '22:22'
  15. volumes:
  16. - '/config:/etc/gitlab'
  17. - '/logs:/var/log/gitlab'
  18. - '/data:/var/opt/gitlab'
  19. shm_size: '256m'

执行 docker-compose -f gitlab-compose.yaml up -d

  1. xiaohui@220200700182:/mnt/c/Users/DELL$ docker-compose -f gitlab-compose.yaml up -d
  2. WARNING: Found orphan containers (dell_db_1, dell_sonarqube_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
  3. Creating dell_web_1 ... done
  4. xiaohui@220200700182:/mnt/c/Users/DELL$

2.3 启动后,多等一会

image.png
wsl docker 安装管理界面
image.png

2.4 external_url

external_url 该参数可以替换掉 git clone 中间的 hostname。

3 个性化设置

点击头像,preference:
image.png
进行语言设置,找到 Localizationimage.png
设置完成,需要注销登录,再次进入,就是中文了。