通过docker-compose部署gitlab和jenkins,方便后续工作
注意:
- gitlab占用资源较多,最好系统内存在8G以上,CPU4核心以上,否则gitlab有可能报错无法启动。
- docker版本用最新版本,低版本的docker可能会导致docker-compose部署的容器网络无法互通,在配置jenkins和gitlab时会出现 no route, no host等错误提示。
安装docker和docker-compose
略过不表,若有需要可以文章下留言,有时间在写
创建必要目录
mkdir /home/docker
cd /home/docker
mkdir jenkins gitlab
chown -R 1000:1000 jenkins
启动容器
复制一下内容保存为docker-compose.yml, 运行docker-compose up -d
,时间比较久,耐心等待,完成启动后运行docker-compose ps
查看容器运行状态,若都是running状态,则表示正常启动
version: "3.8"
services:gitlab:restart: alwaysprivileged: truetty: truecontainer_name: gitlabimage: gitlab/gitlab-ce #选择gitlab社区版本ports:- "80:80"- "8022:22"volumes:- ./gitlab/etc:/etc/gitlab- ./gitlab/log:/var/log/gitlab- ./gitlab/opt:/var/opt/gitlabenvironment:GITLAB_OMNIBUS_CONFIG: |external_url 'http://ip:port' #ip为本机ip,port为80映射的端口gitlab_rails['gitlab_shell_ssh_port'] = sshport #sshport为22映射的端口gitlab_rails['time_zone'] = 'Asia/Shanghai' #时区gitlab_rails['smtp_enable'] = true #弃用邮件功能gitlab_rails['smtp_address'] = "smtp.qq.com" # qq邮箱的smtp地址gitlab_rails['smtp_port'] = 587 #qq邮箱的smtp端口gitlab_rails['smtp_user_name'] = "" #输入自己的qq邮箱gitlab_rails['smtp_password'] = "" #qq邮箱的授权码gitlab_rails['smtp_domain'] = "smtp.qq.com"gitlab_rails['smtp_authentication'] = "login"gitlab_rails['smtp_enable_starttls_auto'] = truegitlab_rails['smtp_tls'] = falsegitlab_rails['smtp_pool'] = falsegitlab_rails['gitlab_email_enabled'] = truegitlab_rails['gitlab_email_from'] = '' #输入自己的qq邮箱gitlab_rails['gitlab_email_reply_to'] = '' #输入自己的qq邮箱gitlab_rails['manage_backup_path'] = true #开启备份功能gitlab_rails['backup_archive_permissions'] = 0644gitlab_rails['backup_keep_time'] = 604800 #日志时长/秒alertmanager['admin_email'] = '' #告警提醒地址,输入自己的qq邮箱jenkins:restart: alwaysprivileged: truetty: truecontainer_name: jenkinsimage: jenkins/jenkins:lts-jdk17ports:- "8080:8080"- "50000:50000"volumes:- ./jenkins:/var/jenkins_home:rw- /var/run/docker.sock:/var/run/docker.sock- /etc/docker:/etc/docker- /usr/bin/docker:/usr/bin/docker- /etc/localtime:/etc/localtime:roenvironment:TZ: Asia/Shanghai
看到这里了,点个赞在走吧。