[Docker] [GitLab] dokcer install and build the latest gitlab Chinese community version (build a small personal "Gitee" or "GitHub")

Get into the habit of writing together! This is the 5th day of my participation in the "Nuggets Daily New Plan · April Update Challenge", click to view the details of the event .

Reference: # docker install gitlab Chinese version (gitlab-ce:11.3.0-ce.0 community version)

1. Installation and startup

1 Introduction and installation of docker

Introduction to Docker: Docker is an open-source application container engine that allows developers to package their applications and dependencies into a portable image , which can then be distributed to any popular  Linux or Windows operating system machine. virtualization . Containers are completely sandboxed and do not have any interface with each other.
  To sum up one sentence: it is more convenient to use docker! They do not affect each other! More convenient!
Installation instructions :

yum install docker -y
复制代码

2 Introduction and installation of Gitlab

GitLab is an open source project for a warehouse management system, using Git as a code management tool and building a web service based on it. The installation method is to refer to GitLab's wiki page on GitHub.
  To sum up one sentence: the warehouse for managing code can be understood as building a small, personal Gitee ~
installation instructions :
Pull the latest Gitlab Chinese Community Edition

docker pull beginor/gitlab-ce:latest
复制代码

创建管理的相关目录 etc(配置) 、log(日志) 、data(数据). (把文件映射到容器外,便于之后管理和升级)

mkdir -p /usr/local/gitlab/etc
mkdir -p /usr/local/gitlab/log
mkdir -p /usr/local/gitlab/data
复制代码

给这些相关目录添加权限 777

chmod 777 /usr/local/gitlab/etc 
chmod 777 /usr/local/gitlab/log 
chmod 777 /usr/local/gitlab/data
复制代码

3 GitLab的启动

参数说明
将http:443映射到外部端口8443
–publish 8443:443
80映射到外部端口8888
–publish 8888:80将web
22映射到外部端口8222
–publish 8222:22将ssh
运行容器名
–name gitlab
重启策略
–restart unless-stopped
挂载目录
–volume /usr/local/gitlab/etc:/etc/gitlab
挂载目录
–volume /usr/local/gitlab/log:/var/log/gitlab
挂载目录
–volume /usr/local/gitlab/data:/var/opt/gitlab
使得容器内的root拥有真正的root权限。否则,container内的root只是外部的一个普通用户权限
–privileged=true

docker run --detach --publish 8443:443 --publish 8888:80 --publish 8222:22 --name gitlab --restart unless-stopped --volume /usr/local/gitlab/etc:/etc/gitlab --volume /usr/local/gitlab/log:/var/log/gitlab --volume /usr/local/gitlab/data:/var/opt/gitlab --privileged=true beginor/gitlab-ce:latest
复制代码

等待返回一串字符串,就说明启动成功了 image.png

二、使用与注意事项

1 开放端口(两种方式)

GitLab启动成功后,有两种方式开放端口号:
开放该docker对应的端口号(如8888、8443、8222) 就是去到对应服务器商(如阿里云、腾讯云、华为云等),设置服务器的防火墙开放端口
配置了nginx,在nginx配置文件里,添加转发端口.(前提也开放了nginx监控的端口,这里是80)
这里使用方法②,参考如下: image.png nginx.config文件(注释的是https,ssl的认证,相关的):

    server {
        listen       80;
        #listen 443 ssl;
        server_name gitlab.nanfangzhe.cn;
        root         /usr/share/nginx/html;
        #ssl_certificate cert/gitlab.nanfangzhe.cn/gitlab.nanfangzhe.cn_bundle.crt;
        #ssl_certificate_key cert/gitlab.nanfangzhe.cn/gitlab.nanfangzhe.cn.key;
        include /etc/nginx/default.d/*.conf;
        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;
                proxy_pass http://127.0.0.1:8888;
        }
    }
复制代码

2. 使用

设置好端口后,访问① http:// + ip + 端口(如:http:// + ip + :8888) ② http:// + 域名
这里访问,直接就能设置密码。(帐号默认是root
image.png
注意,这里 帐号默认是root
image.png
然后,就可以进行操作啦~
image.png
设置一个项目
image.png
添加一个README.md,内容输入:hello,world
image.png
使用 SourceTree 软件,登录帐号和密码 (默认帐号root、刚刚设置的密码),私库就能下来啦~
image.png
完成!
image.png

文章小尾巴

Article writing, templates, and the small tail of the article can be referred to: "Writing "Mindful Thinking""
  Thank you for reading to the end, and two last points~
  ①If you have different views, you are welcome to leave a message and comment below the article.
  ②If it is helpful to you, or if you recognize it, please give a small like and support~
  I am a southerner, a southerner who loves computers and loves the motherland more.

  (The content of the article is for learning reference only. If there is any infringement, I am very sorry, please contact the author to delete it immediately.)

Guess you like

Origin juejin.im/post/7085511846085525540