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文件里面直接设置密码(〃>皿<))