以容器的方式运行GitLab

以容器的方式运行GitLab

 

目录:

 

一、环境及实验目标

二、软硬件需求:

三、准备数据目录

四、运行容器

、配置GitLab

六、访问页面

七、其他注意事项

八、运行附图

 

一、环境及实验目标

实验目标:在一台虚拟机上,准备好Docker环境,使用容器的方式运行gitlab镜像,搭建一台内部私有的gitlab服务器,要能通过http://gitlab.abc.com域名访问。

机器名:gitlab9

IP地址:192.168.3.169

访问网址:http://gitlab.abc.com

 

、软硬件需求:

CPU :最少1核,也能跑,慢!建议2核以上;

内存:最少4GB1GB Ram+3GB Swap),建议4GB Ram以上;

存储:根据各自需要而定,最少5-10GB以上可用空间,建议使用SSD

软件:Ubuntu 16.04.03+Docker 1.12.3(我用的是这个版本)

 

不满足以上配置,在使用中要么会比较慢,要么会报500错误。

 

建议:24GB20GB+空间,可满足100用户的基本使用。

实际生产中使用时,可根据用户数和存储量,确定硬件配置,

查询地址:https://docs.gitlab.com/ce/install/requirements.html

  

、准备数据目录

#gitlab/gitlab-ce容器需要先创建三个目录

#分别存放应用数据、日志和配置文件

#宿主机上/gitlab/data对应容器中/var/opt/gitlab

#宿主机上/gitlab/logs对应容器中/var/log/gitlab

#宿主机上/gitlab/config对应容器中/etc/gitlab

sudo mkdir -p /gitlab/data

sudo mkdir -p /gitlab/logs

sudo mkdir -p /gitlab/config

 

、运行容器gitlab/gitlab-ce

#启动一个gitlab-ce容器

#--hostnameGitLab容器的主机名,不是对外发布的网站名。

 sudo docker run --detach \

    --hostname gitlab.example.com \

    --publish 443:443 --publish 80:80 --publish 2222:22 \

    --name gitlab \

    --restart always \

    --volume /gitlab/config:/etc/gitlab \

    --volume /gitlab/logs:/var/log/gitlab \

    --volume /gitlab/data:/var/opt/gitlab \

    gitlab/gitlab-ce:latest

 

#首次启动可能比较慢,需要等待几分钟的时间。

#可以使用sudo docker ps命令查看当前gitlab容器的状态。

#当它的状态由starting变为health时,说明成功启动了。

 

、配置GitLab

#如果按照上述准备工作,配置好的宿主机上的三个目录,

#GitLab的配置文件在容器中为/etc/gitlab/gitlab.rb

#对应宿主机上的文件为/gitlab/config/gitlab.rb

#直接使用vi编辑器,在宿主机上编辑该文件即可。

sudo vi /gitlab/config/gitlab.rb

 

#注:使用Xshellssh远程登录到宿主机,

#再执行sudo docker exec -it gitlab vi /etc/gitlab/gitlab.rb

#试图到容器中运行vi命令,编辑配置文件,会出错!

 

#只要修改文件中的external_url参数即可,

#指向需要发布的http://gitlab.abc.com网站。

#然后重新启动gitlab容器

sudo docker restart gitlab

 

、访问页面

#在客户端机器上(操作系统为Win7),ip地址为192.168.3.xxx

#修改C:\windows\system32\drivers\etc\hosts文件

#加入192.168.3.169   gitlab.abc.com

#通过网页访问http://gitlab.abc.com

#首次访问需要修改管理员密码,

#然后就可以使用root用户和新密码登录

 

、其他问题及注意事项:

7.1如果启用了SELinuxDocker的运行命令是怎样的?

sudo docker run --detach \

    --hostname gitlab.example.com \

    --publish 443:443 --publish 80:80 --publish 2222:22 \

    --name gitlab \

    --restart always \

    --volume /gitlab/config:/etc/gitlab:Z \

    --volume /gitlab/logs:/var/log/gitlab:Z \

    --volume /gitlab/data:/var/opt/gitlab:Z \

    gitlab/gitlab-ce:latest

否则docker进程在挂载的卷上,没有足够的权限创建配置文件。

 

7.2访问页面报50x故障怎么办?升级后遇到权限问题怎么办?

#当访问页面遇到500错误时,可以尝试重启gitlab容器来解决。

sudo docker restart gitlab

 

#或者在升级新的Docker镜像时,遇到权限问题,

#可以尝试执行gitlab的更新权限命令解决:

sudo docker exec gitlab update-permissions

sudo docker restart gitlab

 

7.3容器已经重启好了,为什么不能访问页面?

#执行sudo docker restart gitlab命令,重启容器

#该命令虽然立刻就能执行完了,

#但容器内部的服务还没有完全起来,

#通过sudo docker ps查看容器状态,

#需要1分多的时间,健康状况才能从starting转换到health

#在此期间访问网站会报502错误!

#待容器的状态转为health以后,才能正常访问网页

 

7.4疑问:启动容器时的hostname是什么作用?是容器的主机名?

还是对外发布的网站名称?什么地方会用到这个域名?

答:--hostname参数GitLab容器的主机名,不是对外发布的网站名。

 

7.5Gitlab容器使用了哪些端口?怎样避免冲突?

#gitlab容器内部开放了80/22/443/8080端口,

#这些端口号也是宿主机常用的端口,不能直接80到80,22到22,这样容易引起冲突

#如果想要将这些端口正确暴露到宿主机上,可以使用--publish参数,

#调整宿主机到容器内的端口映射,避免和宿主机上的端口冲突。

#比如 --publish 8880:80访问主机的8880,实际会转到容器的80端口

#--publish 2222:22访问主机的2222,实际是在访问gitlab容器的22端口


7.6如果编译的方式安装,可以使用MySQL数据库吗?

#强烈建议用户使用PostgreSQL而不是MySQL

#已使用MySQL的用户,也建议迁移到PostgreSQL

#容器的方式运行gitlab,不存在此问题。

 

7.7可以在Docker Toolbox下安装GitLab吗?

#建议使用本地化的方式安装Docker,不要使用Docker Toolbox方式安装。

 

、运行附图:

1-创建目录-运行容器-查看状态-正在启动中

 

5-gitlab容器的状态已正常

 

6-进入容器内部,查看gitlab容器信息

 

7-容器的主机名和IP地址

 

8-需要修改的网站URL

 

9-外部访问Gitlab的网址

 

A-重启gitlab容器以后,大约1分钟左右,容器的状态才从starting变为healthy

 

B-第一次访问gitlab.abc.com网站

 

C-使用root用户和修改后的密码登录到gitlab

 

D-容器重启后,如果时间未到,状态没有变为health,会报502错误

  

 

参考链接:

GitLab Docker images

https://docs.gitlab.com/omnibus/docker/

 

Configuration options

https://docs.gitlab.com/omnibus/settings/configuration.html

 

使用docker部署gitlab应用

http://www.jianshu.com/p/05e3bb375f64

 

gitlab-server环境搭建

http://www.cnblogs.com/gnool/p/6128546.html

 

gitlab / gitlab-ce

APT/YUM repository for GitLab Community Edition packages

https://packages.gitlab.com/gitlab/gitlab-ce/install

 

发布了132 篇原创文章 · 获赞 84 · 访问量 82万+
展开阅读全文

gitlab-runner持续集成,注册出现:500错误。Perhaps you are having network problems

04-28

- gitlab搭建在虚拟机里,gitlab-runner搭建在李刚一台虚拟机。互相能Ping通。 > 注册 gitlab-runner register(dockers exec - it gitlab-runner gitlab-runner register ) >Running in system-mode. >Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): > http://192.168.1.185:10080/ >Please enter the gitlab-ci token for this runner: >avpX5_vu9s3n_H9U5DvH >Please enter the gitlab-ci description for this runner: >[localhost.localdomain]: >Please enter the gitlab-ci tags for this runner (comma separated): >ERROR: Registering runner... failed runner=avpX5_vu status=500 Internal Server Error PANIC: Failed to register this runner. Perhaps you are having network problems 但是,如果使用搭建在阿里云上gitlab的就一切OK。 ``` Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/): http://47.94.19~.~:10080/ Please enter the gitlab-ci token for this runner: Ss-fHdM3h3ZG7tz79Ly4 Please enter the gitlab-ci description for this runner: [aae0b11429ff]: Please enter the gitlab-ci tags for this runner (comma separated): Registering runner... succeeded runner=Ss-fHdM3 Please enter the executor: virtualbox, docker+machine, docker, parallels, ssh, docker-ssh+machine, kubernetes, docker-ssh, shell: shell Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! ``` 请问: gitlab-runner 和gitlab 之间这种局域网网络问题出现的原因是什么?怎么解决? 问答

docker gitlab无法启动

10-10

log信息: ``` {"log":"Thank you for using GitLab Docker Image!\n","stream":"stdout","time":"2019-10-10T09:16:52.21426952Z"} {"log":"Current version: gitlab-ce=11.0.1-ce.0\n","stream":"stdout","time":"2019-10-10T09:16:52.214301816Z"} {"log":"\n","stream":"stdout","time":"2019-10-10T09:16:52.214314713Z"} {"log":"Configure GitLab for your system by editing /etc/gitlab/gitlab.rb file\n","stream":"stdout","time":"2019-10-10T09:16:52.214319953Z"} {"log":"And restart this container to reload settings.\n","stream":"stdout","time":"2019-10-10T09:16:52.214324292Z"} {"log":"To do it use docker exec:\n","stream":"stdout","time":"2019-10-10T09:16:52.214343587Z"} {"log":"\n","stream":"stdout","time":"2019-10-10T09:16:52.214354366Z"} {"log":" docker exec -it gitlab vim /etc/gitlab/gitlab.rb\n","stream":"stdout","time":"2019-10-10T09:16:52.214377118Z"} {"log":" docker restart gitlab\n","stream":"stdout","time":"2019-10-10T09:16:52.214383022Z"} {"log":"\n","stream":"stdout","time":"2019-10-10T09:16:52.214386485Z"} {"log":"For a comprehensive list of configuration options please see the Omnibus GitLab readme\n","stream":"stdout","time":"2019-10-10T09:16:52.21441455Z"} {"log":"https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md\n","stream":"stdout","time":"2019-10-10T09:16:52.214418999Z"} {"log":"\n","stream":"stdout","time":"2019-10-10T09:16:52.214422401Z"} {"log":"If this container fails to start due to permission problems try to fix it by executing:\n","stream":"stdout","time":"2019-10-10T09:16:52.21445327Z"} {"log":"\n","stream":"stdout","time":"2019-10-10T09:16:52.214457817Z"} {"log":" docker exec -it gitlab update-permissions\n","stream":"stdout","time":"2019-10-10T09:16:52.214461178Z"} {"log":" docker restart gitlab\n","stream":"stdout","time":"2019-10-10T09:16:52.214470588Z"} {"log":"\n","stream":"stdout","time":"2019-10-10T09:16:52.214474058Z"} {"log":"Preparing services...\n","stream":"stdout","time":"2019-10-10T09:16:55.216795708Z"} {"log":"Starting services...\n","stream":"stdout","time":"2019-10-10T09:16:55.231112363Z"} {"log":"Configuring GitLab package...\n","stream":"stdout","time":"2019-10-10T09:16:55.231559666Z"} {"log":"/opt/gitlab/embedded/bin/runsvdir-start: line 37: /proc/sys/fs/file-max: Read-only file system\n","stream":"stderr","time":"2019-10-10T09:16:55.237269641Z"} {"log":"Malformed configuration JSON file found at /opt/gitlab/embedded/nodes/fe8ab341c48f.json.\n","stream":"stdout","time":"2019-10-10T09:16:55.751260111Z"} {"log":"This usually happens when your last run of `gitlab-ctl reconfigure` didn't complete successfully.\n","stream":"stdout","time":"2019-10-10T09:16:55.751280615Z"} {"log":"This file is used to check if any of the unsupported configurations are enabled,\n","stream":"stdout","time":"2019-10-10T09:16:55.751283608Z"} {"log":"and hence require a working reconfigure before upgrading.\n","stream":"stdout","time":"2019-10-10T09:16:55.751285925Z"} {"log":"Please run `sudo gitlab-ctl reconfigure` to fix it and try again.\n","stream":"stdout","time":"2019-10-10T09:16:55.75128816Z"} ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览