一、拉取镜像
- docker pull gitlab/gitlab-ce:latest
二、运行容器
docker run --detach \
--hostname localhost \ # 本地访问直接用localhost
--publish 80:80 --publish 443:443
--publish 22:22 \
--name gitlab \
--restart unless-stopped \ # 容器退出时不自动重启(生产环境用always)
--volume $PWD/gitlab/config:/etc/gitlab \
--volume $PWD/gitlab/logs:/var/log/gitlab \
--volume $PWD/gitlab/data:/var/opt/gitlab \
--shm-size 256m \ # 减少内存占用
gitlab/gitlab-ce:latest
docker run --detach --hostname localhost --publish 80:80 --publish 443:443 --publish 22:22 --name gitlab --restart unless-stopped --volume $PWD/gitlab/config:/etc/gitlab --volume $PWD/gitlab/logs:/var/log/gitlab --volume $PWD/gitlab/data:/var/opt/gitlab --shm-size 256m gitlab/gitlab-ce:latest
三、获取原始root用户密码
- docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password