Gitlab for Docker 安裝被坑過程

CentOS 7.5 x64html

Dokcer-ce:18.03linux

Gitlab:10.8.1-ce.0nginx

1) docker pull gitlab/gitlab-ce  獲取鏡像git

2)按照 官方  https://docs.gitlab.com/omnibus/docker/README.htmldocker

sudo docker run --detach \
    --hostname gitlab.example.com \
    --publish 443:443 --publish 80:80 --publish 22: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:latest

結果尷尬了shell

docker: Error response from daemon: 
 driver failed programming external connectivity on endpoint gitlab3 
 (9285fe78ca075cd23dcd42298dd2f3cd58bbe24c3ddaaa71b97ea41cd52e97d4):
 Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use.

既然本地 22 端口被佔用了,換個 2222,結果 OK 了。vim

3)配置 external_url 和 郵件服務app

sudo docker exec -it gitlab vim /etc/gitlab/gitlab.rb




external_url 'http://192.168.29.10:80'

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "xxxx@htd.cn"
gitlab_rails['smtp_password'] = "xxxxpasswd"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = "xxxx@htd.cn"
gitlab_rails['smtp_domain'] = "exmail.qq.com"

配置以後重啓,dom

sudo docker restart gitlab

無限重啓中,等了半天也沒好,確定是容器有問題,去掉 --restart always ,再測試下,而後查看日誌ssh

sudo docker logs gitlab

一看是權限的問題,還有 root 用戶沒有的權限麼,

還真有 SELinux ?, 什麼鬼,Centos 7.x 默認是 開啓的,用不上,關了吧

vim /etc/selinux/config

將SELINUX=enforcing改成SELINUX=disabled


而後 reboot 重啓


[root@localhost ~]# sestatus 
SELinux status:                 disabled
[root@localhost ~]# 


顯示禁用了

4) 修改端口

   因爲服務有限,80 端口,我還要留着給 Nginx 呢,按照官方配置

sudo docker run --detach \
    --hostname gitlab.example.com \
    --publish 8929:80 --publish 2289: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:latest


external_url "http://192.168.29.10:8929"


gitlab_rails['gitlab_shell_ssh_port'] = 2289

啓動了沒法訪問,難道 external_url 不能配置端口麼?

https://www.cnblogs.com/int32bit/p/5310382.html   博主也遇到這個問題

改成  external_url "http://gitlab.example.com",

http://gitlab.example.com:8929  OK 了,覺得大功告成了,添加個用戶試試, 連接 端口號丟了

如何是好,修改 gitlab.rb 的 Nginx 端口號

nginx['redirect_http_to_https_port'] = 8929


重啓

sudo docker restart gitlab

仍是訪問不了,暈菜了。。。。。

忘記 原來 建立容器的是 內部端口指定的是 80, 重啓固然無論用啊

重現構建,大功告成 

sudo docker run --detach \
	--hostname gitlab2 \
	--env GITLAB_OMNIBUS_CONFIG="external_url 'http://192.168.29.10:83/';" \
	--publish 83:83 --publish 2223:2223 \
	--name gitlab2 \
	--volume /srv/gitlab2/config:/etc/gitlab \
	--volume /srv/gitlab2/logs:/var/log/gitlab \
	--volume /srv/gitlab2/data:/var/opt/gitlab \
	gitlab/gitlab-ce:rc

GitLab 安裝內存那叫一個大,什麼都沒有,開了兩個鏡像,佔用了10幾G 的內存

[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            31G         16G         12G         29M        1.3G         13G
Swap:           15G          0B         15G
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
gitea/gitea         latest              ec1e11c59922        35 hours ago        75.2MB
gitlab/gitlab-ce    rc                  6d883eceea3e        2 days ago          1.34GB
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS                       PORTS                                                                 NAMES
7f5804a8eafe        gitlab/gitlab-ce:rc   "/assets/wrapper"   10 minutes ago      Up 10 minutes (healthy)      22/tcp, 80/tcp, 0.0.0.0:83->83/tcp, 443/tcp, 0.0.0.0:2223->2223/tcp   gitlab2
83b9a7380a09        gitlab/gitlab-ce:rc   "/assets/wrapper"   About an hour ago   Up About an hour (healthy)   0.0.0.0:80->80/tcp, 443/tcp, 0.0.0.0:2222->22/tcp                     gitlab
[root@localhost ~]# docker stop gitlab
gitlab
[root@localhost ~]# docker stop gitlab2
gitlab2
[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            31G        1.1G         28G        9.2M        1.2G         29G
Swap:           15G          0B         15G

坑只能入一次,但願後面的人,不要學我

╭~~~╮ (o~.~o)

相關文章
相關標籤/搜索