docker-compose方式安装运行Jenkins
服务器系统:centos 7.6
以docker-compose 编排容器方式安装,当然需提前安装docker-compose环境(见百度->docker-compose环境安装)
docker-compose.yml
version: '3.1'
services:jenkins:image: jenkins/jenkins:2.361.3volumes:- /data/jenkins/:/var/jenkins_home- /var/run/docker.sock:/var/run/docker.sock- /usr/bin/docker:/usr/bin/docker- /usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7ports:- "8080:8080"- "8081:8081"expose:- "8080"- "50000"privileged: trueuser: rootrestart: alwayscontainer_name: jenkinsenvironment:JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'
1.上传到任意一个目录
2.执行部署Jenkins命令
docker-compose up –d
运行完成后,Jenkins已经在后台运行起来了
docker ps
使用服务器ip 地址+端口号浏览器打开
http://192.168.1.183:8080/
进入Jenkins容器查看密码
docker exec -it jenkins /bin/bash
cat /var/jenkins_home/secrets/initialAdminPassword
一直往下走进入主界面
3.进入设置全局工具配置
Jenkins容器中自带git
/usr/bin/git
Jenkins容器中自带jdk
/opt/java/openjdk
需要从外面导入maven到容器中
docker cp apache-maven-3.9.2-bin.zip cf09b3515f61:/usr/local/maven
docker exec -it jenkins /bin/bash
cd /usr/local/maven/
unzip apache-maven-3.9.2-bin.zip
拿到maven路径后配置到Jenkins 中
/usr/local/maven/apache-maven-3.9.2
4.快乐的构建版本了