1. 新建個專用的目錄,然后在里面新建個docker-compose.yml文件:
(gitlab-ce是社區版,當然還有ee,是商業版)
version: '3.6'
services: web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'https://你的公網IP:30080' # Add any other gitlab.rb configuration here, each on its own line ports: - '30080:30080' - '30443:443' - '30022:22' - '3080:80' volumes: - './config:/config:/etc/gitlab' - './logs:/logs:/var/log/gitlab' - './data:/data:/var/opt/gitlab' shm_size: '256m'
2. 啟動docker-compose,并檢查語法:
docker compose up -d
3. 進入容器,之后查看密碼
cat /etc/gitlab/initial_root_password
輸出的結果是:
首先這里面告訴了我們初始 username為root,密碼是?QKHN+xn7H2s/FvyIQ8ZqAqVBkTufEEs4eJXyrxi3FyM=,但是這個文件會在24小時內自動刪除,所以最好還是按照提示去重置一下密碼。
# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.Password: QKHN+xn7H2s/FvyIQ8ZqAqVBkTufEEs4eJXyrxi3FyM=# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
?如果你不想重置密碼,直接訪問?https://你的公網IP:30080,然后輸入初始用戶名和密碼就可以了。
4. 重置密碼
還是訪問?https://你的公網IP:30080,然后在左邊的側邊欄點擊向下的箭頭,然后選擇【Admin Area】-【Overview】-【Users】,然后修改。密碼要求數字+字母,至少8位。
(所以我為什么不直接在DockerCompose文件里面直接設置密碼(〃>皿<))