mkdir /opt/jenkins -p
vim /opt/jenkins/Dockerfile
FROM jenkins/jenkins:lts EXPOSE 8080 50000
vim /opt/jenkins/docker-compose.yml
version: '2' services: jenkins: image: v-jenkins container_name: jenkins build: context: . dockerfile: Dockerfile restart: always privileged: true user: root ports: - '58080:8080' - '50000:50000' environment: JAVA_OPTS: '-Duser.timezone=Asia/Shanghai' volumes: - ./var/jenkins_home:/var/jenkins_home - ./var/run/docker.sock:/var/run/docker.sock - ./usr/bin/docker:/usr/bin/docker - ./usr/lib/x86_64-linux-gnu/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
生成启动
cd /opt/jenkins/
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看日志
docker logs --tail="500" jenkins
docker logs -f jenkins
进入容器
docker exec -it --user root jenkins /bin/bash
cat /var/jenkins_home/secrets/initialAdminPassword
把对应密码粘贴到Jenkins界面
http://192.168.0.101:58080
http://192.168.0.101:50000