赞
踩
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
提示:这里可以添加本文要记录的大概内容:
用docker-compose 部署 Jenkins + Gitlab 环境快速自动部署 SpringBoot项目
提示:以下是本篇文章正文内容,下面案例可供参考
下载地址:https://mirrors.tuna.tsinghua.edu.cn/docker-ce/
代码如下(示例):
1.解压安装包 tar -zxvf docker.**.tgz 2.将文件移动到/usr/bin/文件夹下 cp ../docker/* /usr/bin/ 3.在/etc/systemd/system/创建docker.service(文件内容见2.1) cd /etc/systemd/system touch docker.service vi docker.service .... (见下面1.1) 4.赋文件权限和启动docker chmod +x docker.service # 添加文件权限 systemctl daemon-reload # 重载unit配置文件 systemctl start docker # 启动docker systemctl enable docker.service #设置开机自启 ( 设置开机自启出错:Failed to execute operation: File exists 解决部分:find / -name docker.service rm 删除除自己添加外相同名称的配置文件 )
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
网盘下载: https://pan.baidu.com/s/1_IVwgb9z0sjHCdItwk4bWg 提取码: 9966
(来自于https://blog.csdn.net/CSDNCDN/article/details/130240894)
1、将docker-compose文件移动到 /usr/local/bin/ 目录下
2、给文件授权 chmod +x docker-compose
docker-compose -v
docker-compose --version
docker-compose version
rm -rf /usr/local/bin/docker-compose
[root@localhost ~]# docker search jenkins
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
jenkins DEPRECATED; use "jenkins/jenkins:lts" instead 5651 [OK]
jenkins/jenkins The leading open source automation server 3641
jenkins/jnlp-slave a Jenkins agent which can connect to Jenkins… 156
... 0
[root@localhost ~]# docker pull jenkins/jenkins
创建docker-compose.yml文件,配置jenkins信息
version: '3.1' networks: # 网关配置 docker_net: driver: bridge ipam: driver: default config: - subnet: 172.66.11.0/24 services: jenkins: restart: always image: jenkins/jenkins container_name: jenkins user: root ports: - '8080:8080' # 浏览器访问端口 - '50000:50000' volumes: - /usr/local/maven/:/usr/local/maven # 将本地maven映射到jenkins容器中去 - /root/docker/jenkins/jenkins_home:/var/jenkins_home # 将容器中的jenkins数据映射到服务器 - /usr/bin/docker:/usr/bin/docker - /var/run/docker.sock:/var/run/docker.sock networks: docker_net: ipv4_address: 172.66.11.19
在docker-compose.yml的文件目录下执行
docker-compose up -d
[root@localhost docker]# cd /root/docker/jenkins/jenkins_home/
[root@localhost jenkins_home]# vi hudson.model.UpdateCenter.xml # 修改的文件如下路径为清华开源镜像站路径
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url>
</site>
</sites>
下载自己需要的插件
[root@localhost ~]# docker search gitlab-ce
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gitlab/gitlab-ce GitLab Community Edition docker image based … 3965 [OK]
twang2218/gitlab-ce-zh 汉化的 GitLab 社区版 Docker Image 266
...
[root@localhost ~]# docker pull twang2218/gitlab-ce-zh
docker-compose.yml文件,配置jenkins信息
gitlab: restart: always image: twang2218/gitlab-ce-zh container_name: gitlab hostname: '192.168.14.102' ports: - '8443:443' - '8088:8088' # 浏览器访问端口 - '8022:22' volumes: - /root/docker/config/gitlab:/etc/gitlab - /root/docker/logs/gitlab:/var/log/gitlab - /root/docker/data/gitlab:/var/opt/gitlab environment: TZ: 'Asia/shanghai' GITLAB_OMNIBUS_CONFIG: | external_url 'http://192.168.14.102:8088' gitlab_rails['gitlab_shell_ssh_port'] = 8022 unicorn['port'] = 8888 nginx['listen_port'] = 8088 privileged: true shm_size: '256m' networks: docker_net: ipv4_address: 172.66.11.18
docker-compose up -d
启动异常,日志alertmanager错误(忘记截图了)在gitlab.rb最后一行添加
vi /root/docker/config/gitlab/gitlab.rb
alertmanager['flags'] = {
'cluster.advertise-address' => '127.0.0.1:9093'
}
配置jenkins 的工具
git和jdkjenkins时安装时就会有,所有直接配置容器中的安装路径
还需要安装maven打包项目,所以
下载maven 所需插件
服务器安装maven并映射到容器中去
接下来创建任务,
构建
学无止境
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。