搭建
官方的gitlab 镜像使用的相关mysql和redis均是内部嵌套的。
部署数据库
mysql
运行容器
mkdir -p /home/bubao/disk/data1/opt/mysql/{data,conf.d}
docker run --name mysql \
--restart=always \
--env MYSQL_ROOT_PASSWORD=123456 \
--volume /home/bubao/disk/data1/opt/mysql/data:/var/lib/mysql \
--volume /home/bubao/disk/data1/opt/mysql/conf.d:/etc/mysql/conf.d \
--publish 3306:3306 \
-d mysql:8.0
进入容器
docker exec -it mysql /bin/bash
mysql -h localhost -uroot -p
添加账号,并创建一个用户
CREATE USER 'gitlab'@'%.%.%.%' IDENTIFIED BY '123456';
CREATE DATABASE IF NOT EXISTS `gitlab_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT ALL PRIVILEGES ON `gitlab_production`.* TO 'gitlab'@'%.%.%.%';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
redis
mkdir -p /home/bubao/disk/data1/opt/redis/{conf,data}
docker run --name redis \
--restart=always \
--volume /home/bubao/disk/data1/opt/redis/conf:/usr/local/etc/redis \
--volume /home/bubao/disk/data1/opt/redis/data:/data \
--publish 6379:6379 \
-d redis:5.0-rc4 --appendonly yes
部署gitlab
mkdir -p /home/bubao/disk/data1/opt/gitlab
docker run \
--name gitlab -d \
--restart=always \
--link mysql:mysql \
--link redis:redisio \
--env 'DB_HOST=10.0.0.3' \
--env 'DB_PORT=3306' \
--env 'DB_NAME=gitlab_production' \
--env 'DB_USER=gitlab' \
--env 'DB_PASS=123456' \
--env 'REDIS_HOST=10.0.0.3' \
--env 'REDIS_PORT=6379' \
--publish 10012:22 --publish 10010:80 \
--env 'GITLAB_SSH_PORT=10012' \
--env 'GITLAB_PORT=10010' \
--env 'GITLAB_HOST=10.0.0.3' \
--env 'GITLAB_TIMEZONE=Asia/Shanghai' \
--env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
--env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
--env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
--volume /home/bubao/disk/data1/opt/gitlab/data:/home/git/data \
sameersbn/gitlab:11.2.3
登录
因为gitlab启动时间比较长,等十分钟,访问 ip地址:10010,输入root密码,就能登录了。当然也可以创建新的用户,root用户用于管理其他用户。