这篇文章主要介绍“Docker-compose怎么部署gitlab”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Docker-compose怎么部署gitlab”文章能帮助大家解决问题。docker
这篇文章主要介绍“Docker-compose怎么部署gitlab”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“Docker-compose怎么部署gitlab”文章能帮助大家解决问题。
docker-compose部署gitlab
1、安装docker
安装必要工具
复制代码 代码如下:
[root@vm_10_14_Centos ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
添加docker-ce镜像源并安装
[root@vm_10_14_centos ~]# yum-config-manager --add-repoHttp://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo[root@vm_10_14_centos ~]# yum makecache fast[root@vm_10_14_centos ~]# yum -y install docker-ce[root@gitlab ~]# yum makecache fast[root@vm_10_14_centos ~]# yum -y install docker-ce[root@vm_10_14_centos ~]# systemctl start docker[root@vm_10_14_centos ~]# systemctl enable dockercreated symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
添加docker镜像加速
[root@vm_10_14_centos ~]# vim /etc/docker/daemon.JSON{"reGIStry-mirrors": ["https://9w1hl6Qt.mirror.aliyuncs.com"]}[root@vm_10_14_centos ~]# systemctl daemon-reload[root@vm_10_14_centos ~]# systemctl restart docker[root@vm_10_14_centos ~]# rpm -qa docker[root@vm_10_14_centos ~]# rpm -qa docker-cedocker-ce-18.09.0-3.el7.x86_64[root@vm_10_14_centos ~]# docker --versiondocker version 18.09.0, build 4d60db4[root@vm_10_14_centos ~]# docker versionclient: version: 18.09.0 api version: 1.39 Go version: go1.10.4 git commit: 4d60db4 built: wed nov 7 00:48:22 2018 os/arch: linux/amd64 experimental: falseserver: docker engine - commUnity engine: version: 18.09.0 api version: 1.39 (minimum version 1.12) go version: go1.10.4 git commit: 4d60db4 built: wed nov 7 00:19:08 2018 os/arch: linux/amd64 experimental: false
2、安装docker-compose
下载docker-compose二进制文件并添加执行权限
[root@vm_10_14_centos ~]# curl -l https://GitHub.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose % total % received % xferd average speed time time time current dload upload total spent left speed100 617 0 617 0 0 959 0 --:--:-- --:--:-- --:--:-- 958100 11.2m 100 11.2m 0 0 1824k 0 0:00:06 0:00:06 --:--:-- 2422k[root@vm_10_14_centos ~]# chmod +x /usr/local/bin/docker-compose[root@vm_10_14_centos ~]# docker-compose --versiondocker-compose version 1.23.2, build 1110ad01
3、安装gitlab
(1)编辑docker-compose的yml文件
[root@vm_10_14_centos ~]# mkdir gitlab[root@vm_10_14_centos ~]# cd gitlab/[root@vm_10_14_centos gitlab]# vim docker-compose.yml version: '2'services: gitlab: image: 'twang2218/gitlab-ce-zh:11.1.4' container_name: "gitlab" restart: unless-stopped privileged: true hostname: 'gitlab' environment: tz: 'asia/shanghai' gitlab_omnibus_config: | external_url 'http://129.204.133.242' gitlab_rails['time_zone'] = 'asia/shanghai' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.aliyun.com" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "kimasd102419@aliyun.com" #用自己的aliyun邮箱 gitlab_rails['smtp_passWord'] = "axbc1kof" gitlab_rails['smtp_domain'] = "aliyun.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = true gitlab_rails['gitlab_email_from'] = 'kimasd102419@aliyun.com' gitlab_rails['gitlab_shell_ssh_port'] = 22 ports: - '80:80' - '443:443' - '22:22' volumes: - /opt/gitlab/config:/etc/gitlab - /opt/gitlab/data:/var/opt/gitlab - /opt/gitlab/logs:/var/log/gitlab
(2)创建相关目录
[root@vm_10_14_centos gitlab]# mkdir /opt/gitlab/{config,data,logs} -p[root@vm_10_14_centos gitlab]# ls -l /opt/gitlab/total 12drwxr-xr-x 2 root root 4096 dec 8 11:35 configdrwxr-xr-x 2 root root 4096 dec 8 11:35 datadrwxr-xr-x 2 root root 4096 dec 8 11:35 logs
(3)拉取gitlab中文版镜像
[root@vm_10_14_centos gitlab]# docker pull twang2218/gitlab-ce-zh:11.1.411.1.4: pulling from twang2218/gitlab-ce-zh8ee29e426c26: pull complete 6e83b260b73b: pull complete e26b65fd1143: pull complete 40dca07f8222: pull complete b420ae9e10b3: pull complete a218309dd589: pull complete 5c60fd7ba0ce: pull complete 659c2144b5a3: pull complete 8289bbac0d0e: pull complete 31bbd150e8a7: pull complete 9114e78243fa: pull complete 0b97fa2153bc: pull complete 308c7e15be6a: pull complete b7f31b8e487d: pull complete cbbb6dec5000: pull complete 0241c9ad6a16: pull complete 7fa6f0b53edd: pull complete 1c2861e152b2: pull complete 0536f3466f66: pull complete digest: sha256:3c2372e3285e6d6933Ddebb5ee3ae0c4bbf7cb235084e54d33d7f0ddf4813c4astatus: downloaded newer image for twang2218/gitlab-ce-zh:11.1.4[root@vm_10_14_centos gitlab]# docker image lsrepository tag image id created sizetwang2218/gitlab-ce-zh 11.1.4 1935cc9f8798 4 months ago 1.61gb
(4)启动gitlab的容器
[root@vm_10_14_centos gitlab]# docker-compose up -dcreating network "gitlab_default" with the default drivercreating gitlab ... errorerror: for gitlab cannot start service gitlab: b'driver failed programming external connectivity on endpoint gitlab (9308ca74b8491c556263eac9fb9b0abcb25258d9e2df5733fc4d9143d6b18dcc): error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use'error: for gitlab cannot start service gitlab: b'driver failed programming external connectivity on endpoint gitlab (9308ca74b8491c556263eac9fb9b0abcb25258d9e2df5733fc4d9143d6b18dcc): error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use'error: encountered errors while bringing up the project. [root@vm_10_14_centos gitlab]# vim /etc/ssh/sshd_config [root@vm_10_14_centos gitlab]# systemctl restart sshd[root@vm_10_14_centos gitlab]# netstat -tulnp |grep 22tcp 0 0 0.0.0.0:60022 0.0.0.0:* listen 4044/sshd
这里需要注意的是,由于gitlab容器需要用到22端口,不能与宿主机冲突,这里需要修改宿主机的sshd服务的监听端口
[root@vm_10_14_centos gitlab]# docker-compose psname command state ports------------------------------------------------------------------------------------------------------gitlab /assets/wrapper up (healthy) 0.0.0.0:22->22/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
(5)gitlab设置开机启动
[root@vm_10_14_centos gitlab]# chmod +x /etc/rc.local[root@vm_10_14_centos gitlab]# ls -l /etc/rc.locallrwxrwxrwx. 1 root root 13 jul 7 16:43 /etc/rc.local -> rc.d/rc.local[root@vm_10_14_centos gitlab]# echo "cd /root/gitlab && docker-compose up -d" >>/etc/rc.local[root@gitlab gitlab]# tail -1 /etc/rc.localcd /root/gitlab && docker-compose up -d
(6)gitlab管理界面
地址:http://129.204.133.242
账号:root
密码:首次登陆设置
关于“Docker-compose怎么部署gitlab”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注编程网精选频道,小编每天都会为大家更新不同的知识点。
--结束END--
本文标题: Docker-compose怎么部署gitlab
本文链接: https://lsjlt.com/news/308817.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0