centos7 the use of docker mounted gitlab [turn]

Environment background:

Docker technology has become a popular, recording about the use of docker engine installation gitlab.

test environment:

system software rely
CentOS 7.4 GitLab(latest) docker is 18

 

 

 

Installation process:

 1. Install and start the engine docker

[root @ server-10 ~] # yum install docker-ce -y // need to go to the official docker.repo file 
[root @ Server-10 ~] # systemctl enable Docker 
[root @ Server-10 ~] # systemctl Start Docker

 

2. Get image packages gitlab

[Root @ server-10 ~] # docker pull gitlab / gitlab-ce // something more integrated inside mirror may be relatively large

View downloaded image

[root@server-10 logs]# docker images
REPOSITORY                                TAG                 IMAGE ID            CREATED             SIZE
gitlab/gitlab-ce                          latest              991cd608c116        2 weeks ago         1.59GB

 

3. Prepare the working directory on the local gitlab

[root@server-10 ~]# mkdir -p /data/docker/gitlab/{config,data,logs}

In the above the machine is set up three directories can be mapped to gitlab container configuration file after startup mount the local directory, the data files, log files to the machine, and then can view and edit follow directly in the machine, and no longer operation into the container.

 

4. gitlab start (critical step)

docker run -d --name gitlab --hostname gitlab --restart always -p 4443:443 -p 8888:80 -p 2222:22 -v /data/docker/gitlab/config:/etc/gitlab  -v /data/docker/gitlab/data:/var/opt/gitlab -v /data/docker/gitlab/logs:/var/log/gitlab gitlab/gitlab-ce:latest

 Description:

-d : background

--name : Set the vessel's name;

--hostname : Setting the host name of the vessel;

--restart : Set a container restart policy options: no | on-failure [: max-retries] | always | unless-stopped;

-p (lowercase letters): port mapping, form: [hostPort:] containerPort, if not the host port, random port will be generated on the host;

-v (lower case letters): mounted directories form: [HOST-DIR:] CONTAINER -DIR;

 

4. Check the startup information

[root@server-10 ~]# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED              STATUS                                 PORTS                                                               NAMES
3c8cdd184582        gitlab/gitlab-ce:latest   "/assets/wrapper"        About a minute ago   Up About a minute (health: starting)   0.0.0.0:2222->22/tcp, 0.0.0.0:8888->80/tcp, 0.0.0.0:4443->443/tcp   gitlab

It takes some time to start, after a period of time to see again

[root@server-10 logs]# docker ps 
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                   PORTS                                                               NAMES
3c8cdd184582        gitlab/gitlab-ce:latest   "/assets/wrapper"        3 minutes ago       Up 3 minutes (healthy)   0.0.0.0:2222->22/tcp, 0.0.0.0:8888->80/tcp, 0.0.0.0:4443->443/tcp   gitlab

View local port status

Copy the code
[root@server-10 ~]# netstat -tnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN         
tcp6       0      0 :::2222                 :::*                    LISTEN         
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 :::8888                 :::*                    LISTEN        
tcp6       0      0 :::4443                 :::*                    LISTEN     
Copy the code

Check your phone for the new container gitlab working directory contents

[root@server-10 ~]# tree -L 2 /data/docker/gitlab/
/data/docker/gitlab/
├── config
│   ├── gitlab.rb        // 主要配置文件
│   ├── gitlab-secrets.json
│   ├── ssh_host_ecdsa_key
│   ├── ssh_host_ecdsa_key.pub
│   ├── ssh_host_ed25519_key
│   ├── ssh_host_ed25519_key.pub
│   ├── ssh_host_rsa_key
│   ├── ssh_host_rsa_key.pub
│   └── trusted-certs
├── data
│   ├── backups
│   ├── git-data
│   ├── gitlab-ci
│   ├── gitlab-rails
│   ├── gitlab-shell
│   ├── logrotate
│   ├── postgresql
│   ├── redis
│   └── trusted-certs-directory-hash
└── logs
    ├── gitlab-rails
    ├── gitlab-shell
    ├── logrotate
    ├── postgresql
    ├── reconfigure
    ├── redis
    ├── sidekiq
    ├── sshd
    └── unicorn
Copy the code
[root@server-10 ~]# tree -L 2 /data/docker/gitlab/
/data/docker/gitlab/
├── config
│   ├── gitlab.rb        // 主要配置文件
│   ├── gitlab-secrets.json
│   ├── ssh_host_ecdsa_key
│   ├── ssh_host_ecdsa_key.pub
│   ├── ssh_host_ed25519_key
│   ├── ssh_host_ed25519_key.pub
│   ├── ssh_host_rsa_key
│   ├── ssh_host_rsa_key.pub
│   └── trusted-certs
├── data
│   ├── backups
│   ├── git-data
│   ├── gitlab-ci
│   ├── gitlab-rails
│   ├── gitlab-shell
│   ├── logrotate
│   ├── postgresql
│   ├── redis
│   └── trusted-certs-directory-hash
└── logs
    ├── gitlab-rails
    ├── gitlab-shell
    ├── logrotate
    ├── postgresql
    ├── reconfigure
    ├── redis
    ├── sidekiq
    ├── sshd
    └── unicorn
Copy the code

As can be seen above integrated inside or with a lot of things.

 

5. Log gitlab

Enter the installation gitlab container in the browser host address, in the form of  IP: PORT

First login set a new password, and then log on to the next screen, the user name: root , Password: < Previous set password  >

Later you can use.

 

6. Troubleshooting

If the initial login browser 502 check to see if a port conflict, modify the file gitlab.rb port-related items  Unicorn [ 'Port'] = PORT ;

Can also be based logs directory information tracking and tracing, if GitLab external URL must include a schema and FQDN , please try to modify the configuration item format external_url gitlab.rb files  =  'gitlab.xxx.com' or external_url ' HTTP: / / 138.138.82.10 '.

 

7. Update GitLab

If the above method to install, update, change is simple: stop gitlab container, remove the stop gitlab container, get a new image, use the original start command to start a new gitlab container again. Do not worry about data loss, as long as consistent with previous mount directory, it will automatically read the data in the original directory host.

 

Attached commonly used command gitlab

gitlab-ctl reconfigure // reapply gitlab configuration
gitlab-ctl restart // restart gitlab service
gitlab-ctl status // View gitlab running state
gitlab-ctl stop // stop gitlab service
gitlab-ctl tail // Check gitlab Run Log

 

End.

 

Transfer: https: //www.cnblogs.com/ding2016/p/10422605.html

Guess you like

Origin www.cnblogs.com/zxcnn/p/11502369.html