拉取镜像
docker pull jenkins/jenkins:lts-alpine
新建docker-compose.yml文件
vi docker-compose.yml
内容如下:
version: '3'
services:
jenkins:
restart: always
image: jenkins/jenkins:lts-alpine
ports:
- "14008:8080"
- "14005:50000"
volumes:
- "/var/jenkins_homt"
deploy:
replicas: 1
restart_policy:
condition: on-failure
placement:
constraints: [node.hostname == worker]
然后开始构建
docker-compose up -d
接着容器就开始运行起来了,访问:
http://0.0.0.0:14008
可以看到管理界面
然后进入docker容器
docker exec -it 5c99a626b46c /bin/bash
查看管理员密码
cat /var/jenkins_homt/secrets/initialAdminPassword
复制出现的密码到管理页面即可