普通方式
yum安装
代码语言:javascript复制 sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install fontconfig java-11-openjdk
yum install jenkins
常用命令
代码语言:javascript复制systemctl enable jenkins
systemctl start jenkins
systemctl status jenkins
https://pkg.jenkins.io/redhat-stable/
https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos
docker-compose.yml
代码语言:javascript复制version: '3.1'
services:
jenkins:
image: jenkins/jenkins:2.361.4-lts-jdk11
volumes:
- ./data/jenkins/:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/bin/docker
- .ssh:/root/.ssh
ports:
- "8088:8080"
# 容器内获取宿主机的root权限
# privileged: true
user: root #要不 docker pull 会没权限
restart: always
container_name: jenkins
# environment:
# JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'
如上,为了在容器内使用docker
命令,所以额外挂载了
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/bin/docker
但是,这种只在Linux下可用,Mac下我没成功,所以下面的介绍都是基于CentOS
虚拟机的:虚拟机里安装了docker,docker-compose
[root@nfsFileSystem vagrant]# cd docker-jenkins/
#启动容器
[root@nfsFileSystem docker-jenkins]# docker-compose up -d