centos7使用docker安装使用gitlab从入门到精通 | 少将全栈
  • 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

centos7使用docker安装使用gitlab从入门到精通

点滴 admin 7年前 (2017-09-08) 3771次浏览 已收录 扫描二维码

操作系统是centos7 64位 使用的是root用户

前提请先安装docker,系统内核必须3.10以上 内存最好4G以上 (这里是1G的)

执行uname  -r 查看

[root@VM_104_126_centos ~]# uname -r
3.10.0-514.16.1.el7.x86_64

假设我公网ip是168.168.168.168  

ps:如果你是内部使用,可以使用局域网ip假设你局域网ip是192.168.1.168 如果是局域网安装就用你局域网ip替换公网ip

先安装docker

[root@nanhaidetianzhi ~]# sudo tee /etc/yum.repos.d/docker.repo <<-’EOF’

[dockerrepo]

name=Docker Repository

baseurl=https://yum.dockerproject.org/repo/main/centos/7/

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

EOF

[root@nanhaidetianzhi ~]#  yum  -y  install docker-engine

[root@nanhaidetianzhi ~]# systemctl enable docker.service

[root@nanhaidetianzhi ~]# systemctl start docker

[root@nanhaidetianzhi ~]# systemctl status docker

 

这边的环境早就安装好Docker了。

运行systemctl status docker

[root@VM_104_126_centos ~]# systemctl status docker
* docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2017-09-08 13:35:33 CST; 28min ago
     Docs: http://docs.docker.com
 Main PID: 30243 (dockerd-current)
   CGroup: /system.slice/docker.service
           |-30243 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --selinux-enabled --log-d...
           `-30247 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc --run...
Sep 08 13:35:33 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:35:33.441903623+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
Sep 08 13:35:33 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:35:33.470988735+08:00" level=info msg="Loading containers: done."
Sep 08 13:35:33 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:35:33.471051060+08:00" level=info msg="Daemon has completed initialization"
Sep 08 13:35:33 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:35:33.471074873+08:00" level=info msg="Docker daemon" commit="3a094bd/1.12.6" graphdriver=devicemapper version=1.12.6
Sep 08 13:35:33 VM_104_126_centos systemd[1]: Started Docker Application Container Engine.
Sep 08 13:35:33 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:35:33.479783844+08:00" level=info msg="API listen on /var/run/docker.sock"
Sep 08 13:36:31 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:36:31.266338435+08:00" level=info msg="{Action=create, Username=root, LoginUID=0, PID=30420}"
Sep 08 13:36:34 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:36:34.169349500+08:00" level=error msg="Attempting next endpoint for pull after error: unauthorized: authentication required"
Sep 08 13:36:35 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:36:35.479211168+08:00" level=error msg="Not continuing with pull after error: Error: image library/gitlab:latest not found"
Sep 08 13:37:03 VM_104_126_centos dockerd-current[30243]: time="2017-09-08T13:37:03.957275751+08:00" level=info msg="{Action=create, Username=root, LoginUID=0, PID=30483}"

docker安装完成

ps:由于docker仓库在国外,国内长城防火墙的限制导致拉去很慢,可以去这个网站注册 进行加速下载

https://www.daocloud.io/mirror#accelerator-doc

centos7使用docker安装使用gitlab从入门到精通

 

直接选择对应操作系统,复制命令执行,这里是centos

[root@VM_104_126_centos ~]# curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://60037054.m.daocloud.io
docker version >= 1.12
{"registry-mirrors": ["http://60037054.m.daocloud.io"]}
Success.
You need to restart docker to take effect: sudo systemctl restart docker 

 

好了。

然后重启docker服务(systemctl restart docker这个命令是重启)就可以加速了

如果你的电脑没有安装pwgen请先安装这个,(yum -y install pwgen)后面会用到

[root@VM_104_126_centos ~]# yum -y install pwgen
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
epel                                                                                                                                                                                                                                                   | 4.3 kB  00:00:00     
extras                                                                                                                                                                                                                                                 | 3.4 kB  00:00:00     
gitlab_gitlab-ce/x86_64/signature                                                                                                                                                                                                                      |  836 B  00:00:00     
gitlab_gitlab-ce/x86_64/signature                                                                                                                                                                                                                      | 1.0 kB  00:00:00 !!! 
gitlab_gitlab-ce-source/signature                                                                                                                                                                                                                      |  836 B  00:00:00     
gitlab_gitlab-ce-source/signature                                                                                                                                                                                                                      |  951 B  00:00:00 !!! 
os                                                                                                                                                                                                                                                     | 3.6 kB  00:00:00     
updates                                                                                                                                                                                                                                                | 3.4 kB  00:00:00     
(1/5): epel/7/x86_64/group_gz                                                                                                                                                                                                                          | 170 kB  00:00:00     
(2/5): epel/7/x86_64/updateinfo                                                                                                                                                                                                                        | 817 kB  00:00:00     
(3/5): extras/7/x86_64/primary_db                                                                                                                                                                                                                      | 191 kB  00:00:00     
(4/5): updates/7/x86_64/primary_db                                                                                                                                                                                                                     | 7.8 MB  00:00:00     
(5/5): epel/7/x86_64/primary_db                                                                                                                                                                                                                        | 4.8 MB  00:00:00     
(1/2): gitlab_gitlab-ce-source/primary                                                                                                                                                                                                                 |  175 B  00:00:03     
(2/2): gitlab_gitlab-ce/x86_64/primary                                                                                                                                                                                                                 | 912 kB  00:00:06     
Determining fastest mirrors
gitlab_gitlab-ce                                                                                                                                                                                                                                                      293/293
Resolving Dependencies
--> Running transaction check
---> Package pwgen.x86_64 0:2.07-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================
 Package                                                         Arch                                                             Version                                                                Repository                                                      Size
==============================================================================================================================================================================================================================================================================
Installing:
 pwgen                                                           x86_64                                                           2.07-1.el7                                                             epel                                                            24 k

Transaction Summary
==============================================================================================================================================================================================================================================================================
Install  1 Package

Total download size: 24 k
Installed size: 37 k
Downloading packages:
pwgen-2.07-1.el7.x86_64.rpm                                                                                                                                                                                                                            |  24 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pwgen-2.07-1.el7.x86_64                                                                                                                                                                                                                                    1/1 
  Verifying  : pwgen-2.07-1.el7.x86_64                                                                                                                                                                                                                                    1/1 

Installed:
  pwgen.x86_64 0:2.07-1.el7                                                                                                                                                                                                                                                   

Complete!

 

然后执行下面三条命令,从docker仓库拉去代码

docker  pull  sameersbn/gitlab 

docker  pull  sameersbn/redis 

docker  pull  sameersbn/postgresql 

 

[root@VM_104_126_centos ~]# docker  pull  sameersbn/gitlab
Using default tag: latest
Trying to pull repository docker.io/sameersbn/gitlab ... 
latest: Pulling from docker.io/sameersbn/gitlab
cb56c90f0b30: Pull complete 
0acc551e5716: Pull complete 
8956dcd35143: Pull complete 
908242721214: Pull complete 
b44ff14dd3bb: Pull complete 
bfecf19f805b: Pull complete 
af5d9c80f987: Pull complete 
c62bc6caea23: Pull complete 
c2ede0fef898: Pull complete 
8a2325c8c3e4: Pull complete 
5b0c2d80b1a3: Pull complete 
bf00e79aff66: Pull complete 
Digest: sha256:2aac59cc3343d5ab6553349cba7f51ce34708be3a7c4b507b0d878e79d915aa1
[root@VM_104_126_centos ~]# docker  pull  sameersbn/redis 
Using default tag: latest
Trying to pull repository docker.io/sameersbn/redis ... 
latest: Pulling from docker.io/sameersbn/redis
30d541b48fc0: Pull complete 
8ecd7f80d390: Pull complete 
46ec9927bb81: Pull complete 
2e67a4d67b44: Pull complete 
7d9dd9155488: Pull complete 
14d49618a9fd: Pull complete 
aad64f368552: Pull complete 
e15b7db74be0: Pull complete 
Digest: sha256:b03bf1307ed31a9dff21e23d1ada62dc80e3f29fcc70582d51f4cf9895c9fecc
[root@VM_104_126_centos ~]# docker  pull  sameersbn/postgresql 
Using default tag: latest
Trying to pull repository docker.io/sameersbn/postgresql ... 
latest: Pulling from docker.io/sameersbn/postgresql
c60055a51d74: Pull complete 
755da0cdb7d2: Pull complete 
969d017f67e6: Pull complete 
37c9a9113595: Pull complete 
a3d9f8479786: Pull complete 
e43d9de53575: Pull complete 
a16c58ae6f28: Pull complete 
b55b7a197c94: Pull complete 
d330dd15576f: Pull complete 
a410f2b7d073: Pull complete 
Digest: sha256:68239871c61acc08bc52d703c02a7430ba63d2b02b1c5567ba59d9b1e5ffb10a

 

然后执行docker image就可以看见你拉去的镜像了。

[root@VM_104_126_centos ~]# docker images
REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
docker.io/sameersbn/gitlab       latest              06a14df77e35        45 hours ago        1.687 GB
docker.io/redis                  latest              d4f259423416        6 weeks ago         105.9 MB
docker.io/sameersbn/redis        latest              d8f7b0e07097        6 weeks ago         203.4 MB
docker.io/nginx                  latest              3448f27c273f        4 months ago        109.4 MB
docker.io/sameersbn/postgresql   latest              409a9e95e432        7 months ago        234 MB

 

 

然后按顺序执行下面语句,未完待续,尽请期待!

[root@VM_104_126_centos ~]#docker run --name gitlab-postgresql -d 
                         --env ’DB_NAME=gitlabhq_production’ 
                         --env ’DB_USER=gitlab’ --env ’DB_PASS=password’ 
                         --env ’DB_EXTENSION=pg_trgm’ 
                         --volume /data/docker/gitlab/postgresql:/var/lib/postgresql 
                         sameersbn/postgresql

[root@VM_104_126_centos ~]#docker run --name gitlab-redis -d 
                            --volume /data/docker/gitlab/redis:/var/lib/redis 
                            sameersbn/redis       

喜欢 (0)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。