CentOS-6-Docker-安装-Gitlab

#安装
yum install docker-io docker-io-devel -y

#启动
service docker start
#设置开机自动启动
chkconfig docker on

#下载到本地镜像
#docker pull docker.io/gitlab/gitlab-ce
docker pull gitlab/gitlab-ce

#git.*****.com

#后台运行gitlab hostname设置为git.****.com ,容器端口22,443,22映射主机的80,443,2222,容器的/etc/gitlab,/var/log/gitlab,var/opt/gitlab映射到主机/srv/gitlab/config、/srv/gitlab/logs、/srv/gitlab/data目录,名字设置为gitlab,自动启动
docker run --detach \
 --hostname git.******.com \
 --publish 80:80 --publish 443:443 --publish 2222: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 gitlab/gitlab-ce

#开启相应的端口
#主机开始80 443 2222端口
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -p tcp --dport 2222 -j ACCEPT

#查看gitlab日志
docker logs -f gitlab


##########################
#nginx
#nginx proxy
vim /etc/nginx/conf.d/git.*****.con.conf

server {
    listen                80;
    server_name           git.*****.com;

    location / {
      proxy_pass      http://127.0.0.1:8080;
      proxy_redirect  http://127.0.0.1:8080/ /;
      proxy_read_timeout 60s;

      # May not need or want to set Host. Should default to the above hostname.
      proxy_set_header          Host            $host;
      proxy_set_header          X-Real-IP       $remote_addr;
      proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}