GitLab With Docker

Install Docker

Uninstall old versions

If there is no older version, skip.

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \

Set up the repository

Install requirements

sudo yum install -y yum-utils \
  device-mapper-persistent-data \

Set up stable repository

sudo yum-config-manager \
    --add-repo \

Install docker engine

sudo yum install docker-ce docker-ce-cli

Start Docker

sudo systemctl start docker

GitLab image

Pull image

sudo docker pull gitlab/gitlab-ce

Run GitLab

sudo docker run --detach \
  --hostname \
  --publish 8443:443 --publish 8080:80 --publish 8022:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \

Reverse Proxy

Install Nginx

Add Nginx repository

sudo yum install epel-release

Install nginx

sudo yum install nginx

Start nginx

sudo systemctl start nginx


server {
	listen 80;

	location / {
		proxy_set_header HOST $host;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Open port

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --reload


掘金 - 使用Docker搭建GitLab