当前位置: 代码迷 >> 综合 >> docker-compose 安装 jenkins
  详细解决方案

docker-compose 安装 jenkins

热度:24   发布时间:2023-11-09 17:49:50.0

目录

[root@junmo jenkins]# tree -L 1
.
├── data
├── jenkins.yml
└── passwd.txt1 directory, 2 files
[root@junmo jenkins]# 

docker-compose.yml

version: '3.1'
services:jenkins:image: jenkins/jenkins:ltsrestart: alwayshostname: jenkinscontainer_name: jenkinsprivileged: true  # 特权模式user: rootports:- 10080:8080- 50000:50000environment:TZ: Asia/Shanghaivolumes:- ./data:/var/jenkins_home   # jenkins数据目录- /opt/softs/maven/maven3.8:/usr/local/maven # maven目录- /opt/softs/java/jdk8:/usr/local/jdk1.8.0_261 # jdk目录- /var/run/docker.sock:/var/run/docker.sock  # docker目录- /usr/bin/docker:/usr/bin/docker  # docker目录## 目录挂载说明:
## Jenkins使用宿主机的maven、jdk、docker
## 需要自行下载和安装maven和jdk,这两个软件安装都很方便,直接下载tar文件后,解压缩到 /usr/local/目录即可
## - /usr/local/apache-maven-3.6.3:/usr/local/maven
## - /usr/local/jdk1.8.0_261:/usr/local/jdk1.8.0_261
## - /var/run/docker.sock:/var/run/docker.sock
## - /usr/bin/docker:/usr/bin/docker
## 故将宿主机的maven、jdk、docker均挂载到Jenkins的docker配置文件中

启动

docker-compose -f jenkins.yml up -d		# 启动
docker-compose -f jenkins.yml down		# 关闭
docker-compose -f jenkins.yml restart	# 重启

docker安装jenkins

docker run -d --user=root  \
--restart=always --privileged=true \
--name jenkins -p 10080:8080 -p 50000:50000 \
-v /opt/jenkins/data:/var/jenkins_home   \ 			# jenkins数据目录 
-v /opt/soft/maven/maven3.8:/usr/local/maven  \		# maven目录
-v /opt/soft/jdk/jdk8:/usr/local/jdk1.8.0_261 \ 	# jdk目录
-v /var/run/docker.sock:/var/run/docker.sock  \ 	# docker目录
-v /usr/bin/docker:/usr/bin/docker   \   			# docker目录
jenkins/jenkins
  相关解决方案