配置 docker-compose.yml 文件
# 创建数据目录
mkdir -p /docker/jenkins
cd /docker/jenkins
cat > /docker/jenkins/docker-compose.yml << EOF
version: '3.1'
services:
jenkins:
image: jenkinsci/blueocean
container_name: jenkins
privileged: true
restart: always
user: root
environment:
TZ : "Asia/Shanghai"
ports:
- '8888:8080'
volumes:
- './jenkins_home:/var/jenkins_home'
- '/etc/localtime:/etc/localtime:ro'
- '/var/run/docker.sock:/var/run/docker.sock'
- '/usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7'
- '~/.ssh:/var/jenkins_home/.ssh'
- '~/.m2:/root/.m2'
EOF
使用docker-compose up -d
运行
docker-compose up -d
打印日志获取启动密码
docker-compose exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
602cda5994374ce59430f2ffc8714245
访问 运行主机ip:8888
接下来的部分跟普通安装的 Jenkins 没有区别