gitlab需要redis,一起安装了
新建gitlab和redis挂载目录
mkdir -p /data/docker/redis/data
mkdir -p /data/docker/redis/logs
mkdir -p /data/docker/redis/confmkdir -p /data/docker/gitlab/data
mkdir -p /data/docker/gitlab/logs
mkdir -p /data/docker/gitlab/config
给权限
chmod -R 777 /data/docker/redis
chmod -R 777 /data/docker/gitlab
到/data/docker/gitlab目录下新建docker-compose.yml 文件
vi docker-compose.yml
version: '3'services:redis:container_name: redisimage: redisrestart: alwaysenvironment:REDIS_PASSWORD: "password"ports:- 6379:6379volumes:- /data/docker/redis/conf:/etc/redis- /data/docker/redis/data:/data- /data/docker/redis/logs:/logscommand: ["redis-server","/etc/redis/redis.conf"]networks:gitlab_network:aliases:- redisdepends_on:- redis_configredis_config:container_name: redis_configimage: rediscommand: ["sh", "-c", "echo 'requirepass password' > /etc/redis/redis.conf"]volumes:- /data/docker/redis/conf:/etc/redisnetworks:gitlab_network:gitlab:container_name: gitlabimage: 'gitlab/gitlab-ce:15.11.2-ce.0'restart: alwaysdepends_on:- redisenvironment:GITLAB_OMNIBUS_CONFIG: |external_url= "https://xxx.com"redis_host= "redis"redis_port= "6379"redis_password= "password"ports:- "8343:443"- "8380:80"- "8322:22"volumes:- /data/docker/gitlab/config:/etc/gitlab- /data/docker/gitlab/data:/var/opt/gitlab- /data/docker/gitlab/logs:/var/log/gitlabnetworks:gitlab_network:networks:gitlab_network:driver: bridge
/data/docker/redis/conf目录新建redis.conf空配置
touch redis.conf
启动容器
docker-compose up -d
修改gitlab root密码
docker exec -it gitlab bash 进入docker
输入
gitlab-rails console production
换行,再输入
user = User.find_by(username: 'root')
user.password = 'password'
user.password_confirmation = 'password'
user.save!
exit
重启容器
docker-compose restart
-------------------------------------------------------分割线----------------------------------------------------------
如果想要gitlba支持https
进入gitlab容器
docker exec -it gitlab bash
修改gitlab.rb文件
vim /etc/gitlab/gitlab.rb (可能需要使用 apt update install vim 安装vim)
external_url 'https://xx.com'
#/etc/gitlab/ssl/server.crt /etc/gitlab/ssl/server.key路径依据实际情况更换
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"# 下面为http跳转https配置,不需要可以不加
nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
nginx['listen_port'] = 443 #docker部署,容器内端口
容器内继续输入
gitlab-ctl reconfigure
exit;退出容器,重启
docker-compose restart