您的位置:首页 > 运维架构 > Docker

Mac通过Docker部署Gitlab实践

2017-01-22 01:15 761 查看


Mac通过Docker部署Gitlab实践



http://www.jianshu.com/p/b983db7e7c90
http://www.jianshu.com/p/b983db7e7c90 http://www.jianshu.com/p/b983db7e7c90 http://www.jianshu.com/p/b983db7e7c90


1. Docker ToolBox

非常方便实用的工具。
简介:

http://udn.yyuap.com/article-2163-1.html

下载地址:

https://www.docker.com/products/docker-toolbox

官网下载需要翻墙,这里提供一个网盘地址方便大家下载:

2016年5月22日

1.11.1b版本:http://pan.baidu.com/s/1i5CVuT3 提取密码:wqqv

Docker ToolBox集成了以下各部件:
Docker Machine
Docker Swarm
Docker Compose
Docker Registry
Docker Engine
Kitematic
Docker Toolbox安装:



安装完成


2. GitLab

装完Docker Toolbox,会出现这两个应用程序,第一个是命令行模式,第二个是GUI模式。



Docker终端和GUI

打开Kitematic,输入gitlab,搜索,会现非常多可选项,这里选择第一个gitlab-ce,这个是官方版本,集成了gitlab所需的所有部件。



通过Kinematic创建Gitlab实例

点击Create创建,这里可能会很慢,经常到后面卡住,后来同事介绍了一个非常好用的东西,加速器!


3. 加速器:

网址:https://dashboard.daocloud.io/mirror

点击立即开始-接入自有主机-我已有一台主机-选择MAC-直接点击[安装好了](因为上面已经长过Toolbox)



daocloud加速器



接入



等待接入

打开终端:
MacBook-Pro:~ wangwenjie$ docker-machine ssh default

##        .

## ## ##        ==

## ## ## ## ##    ===

/"""""""""""""""""\___/ ===

~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~

\______ o          __/

\    \        __/

\____\_______/

_                _  ____    _            _

| |__  ___  ___ | |_|___ \ __| | ___  ___| | _____ _ __

| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|

| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|  <  __/ |

|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|

Boot2Docker version 1.11.1, build HEAD : 7954f54 - Wed Apr 27 16:36:45 UTC 2016

Docker version 1.11.1, build 5604cbe

docker@default:~$ curl -sSL https://get.daocloud.io/daomonit/install.sh | sh -s

f1bc7a7ea6d1345c4d783dec6935ce61f0fba659

* Installing Daomonit with docker ...

+ sudo -E sh -c docker info

Containers: 0

Running: 0

Paused: 0

Stopped: 0

Images: 0

Server Version: 1.11.1

Storage Driver: aufs

Root Dir: /mnt/sda1/var/lib/docker/aufs

Backing Filesystem: extfs

Dirs: 9

Dirperm1 Supported: true

Logging Driver: json-file

Cgroup Driver: cgroupfs

Plugins:

Volume: local

Network: bridge null host

Kernel Version: 4.4.8-boot2docker

Operating System: Boot2Docker 1.11.1 (TCL 7.0); HEAD : 7954f54 - Wed Apr 27 16:36:45 UTC 2016

OSType: linux

Architecture: x86_64

CPUs: 1

Total Memory: 1.955 GiB

Name: default

ID: CTMT:VJ42:V4TA:YFFC:YIAL:KT6Y:PDPY:4J7J:4Y7C:KTIO:3OFN:MW53

Docker Root Dir: /mnt/sda1/var/lib/docker

Debug mode (client): false

Debug mode (server): true

File Descriptors: 16

Goroutines: 61

System Time: 2016-05-22T08:12:27.39348255Z

EventsListeners: 1

Registry: https://index.docker.io/v1/ 
Labels:

provider=virtualbox

* Downloading Daomonit using docker pull daocloud.io/daocloud/daomonit

Using default tag: latest

latest: Pulling from daocloud/daomonit

7ccc78f8af6d: Pull complete

a3ed95caeb02: Pull complete

322f573c95ad: Pull complete

Digest: sha256:c44458d624bdb54e4e903bf78910ae89b2996e06a41736e2924a59aee6677369

Status: Downloaded newer image for daocloud.io/daocloud/daomonit:latest

Error: No such image or container: daomonit

* Configuring Daomonit...

[05/22/16 08:12:47] [DEBG] Writing configuration file /etc/daocloud/daomonit.yml

[05/22/16 08:12:47] [INFO] You have successfuly save your config fie.

* Install DaoTools...

% Total    % Received % Xferd  Average Speed  Time    Time    Time  Current

Dload  Upload  Total  Spent    Left  Speed

100  273  100  273    0    0    937      0 --:--:-- --:--:-- --:--:--  938

100  257  100  257    0    0    592      0 --:--:-- --:--:-- --:--:--  592

100  309  100  309    0    0    545      0 --:--:-- --:--:-- --:--:--    0

100  2802  100  2802    0    0  4428      0 --:--:-- --:--:-- --:--:--  4428

* Starting Daomonit...

64a5ea392799a814d31ccf3e23fe68632ff7e215b962ef10803832b4f669bf0d

*********************************************************************

*********************************************************************

***

***  Installed and Started Daomonit with docker

***

***  NOTICE:

***  You can pull image very Fast by dao, For Example:

***    dao pull ubuntu

***

*********************************************************************

*********************************************************************

docker@default:~$

完成,返回网页,会弹出提示:



接入完成


4. 通过加速器获取Gitlab-ce镜像

点击右下角加速器图标,输入gitlab-ce搜索:



通过加速器查找Gitlab镜像

选择镜像,点击部署:



部署

选择版本,拉取镜像(200多兆,10分钟左右)



选择镜像版本

docker@default:~$ dao pull gitlab/gitlab-ce:8.7.6-ce.0

# ----------------------------------------------------------------------------
# DaoCloud ToolBox for Docker
#
# DaoCloud, Inc. (c) 2016
#
# Fastest way to pull image from Docker Hub
# ----------------------------------------------------------------------------

Pulling repository gitlab/gitlab-ce:8.7.6-ce.0

4b37163c83a4: Starting download
4b37163c83a4: Download complete

Pull gitlab/gitlab-ce:8.7.6-ce.0 complete, you can find it with 'docker images'

完成。返回客户端,点击[+NEW]-My Images,可以看到刚刚下载的gitlab-ce镜像(如果没有出现,多点几下,稍等一会儿),点击[CREATE]创建一个实例并启动。



通过镜像创建Gitlab实例

启动完成,忽略右边的502,这是预览,在还没有完全启动起来的时候就开始生成预览了,所以502,好像也没有刷新按钮,忽然它。



启动完成

点击这个502预览,弹出浏览器页面如下,安装基本上算完成了。



安装完成,本地访问

重置密码,确认,返回登录,默认管理员用户是root,输入刚过重置的密码,登录:



设置密码,登录!


5. 端口映射

目前访问的这个地址http://192.168.99.100:32769 是docker虚拟出来的,只能通过本机打开,同一网络的其他机器想要访问的话,还要做下端口映射或是网卡桥接(参考:http://www.tuicool.com/articles/Rr6Jb2 )。
这里介绍一种简单粗暴的方法,装个VirtualBox,打开你会看到一个default实例,其实就是Docker Toolbox生成的那个default:



通过VisualBox做端口映射

设置-网络-端口转发-新增,增加一条

将docker的32769端口转发到本机的内网ip的8088端口



添加端口映射规则

完成:



端口映射完成

注意:其中的32769这个端口在docker中配置,点击端口,修改,保存(会自动重启),之后这个端口就不会变了,如果没改过的话,可能每次重启端口都是不一样的。



通过配置固定Gitlab端口号


6. 有兴趣纯手工安装可以参考

a.http://www.cnblogs.com/zhepama/p/3956567.html

b.https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md


7. 安装sameersbn/gitlab版镜像遇到的问题

网上看了很多教程,很多人装的是sameersbn的版本,这个版本没有集成redis和mysql,需要另外安装。

在使用官方版本之前也试过这个,出现了各种问题,最后虽然安装成功,git pull都ok了,push的时候却提示说Gitlab API不可用。

很多人说是配置问题,需要做如下修改:

gitlab的配置依赖于三个文件:

/home/git/gitlab/config/unicorn.rb:配置ruby提供的服务端口,ip

/home/git/gitlab/config/gitlab.yml:配置gitlab服务的端口,ip

/home/git/gitlab-shell/config.yml:配置gitlab-shell要调用的API接口

这三个文件的配置要保持一致,只需要更改ip和端口就可以了,其他不用动。

unicorn.rb:第40行改成

listen "10.180.108.100:8088", :tcp_nopush => true #本机ip

gitlab.yml:第18行和第19行改成

host: 10.180.108.100 #本机ip

port: 8088 #本机端口

config.yml:第5行改成

gitlab_url: "http://10.180.108.100:8088/" #本机ip

改完后执行gitlab-ctl reconfigure重新加载配置。

但是修改之后依然不可用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: