安装jenkins
image.pngdocker-compose.yml:
version: '3'
services:
jenkins:
image: 'jenkins/jenkins:lts'
container_name: jenkins
restart: always
ports:
- '8080:8080'
- '50000:50000'
volumes:
- '/data/jenkins_home:/var/jenkins_home'
docker_run_install_jenkins.sh:
#!/bin/bash
docker run --name jenkins \
-d \
-p 8080:8080 \
-p 50000:50000 \
-v /data/jenkins_home:/var/jenkins_home \
--restart always \
jenkins/jenkins:lts
pre_install_jenkins.sh:
#!/bin/bash
mkdir -p /data/jenkins_home
chown -R 1000:1000 /data/jenkins_home
在jenkins目录运行以下命令:
# 给脚本授权
chmod u+x *.sh
# 创建Jenkins数据目录(用作持久卷)
./pre_install_jenkins.sh
# 启动Jenkins容器
docker-compose up -d
运行 cat /data/jenkins_home/secrets/initialAdminPassword 获取初始密码。
网友评论