Docker-compose构建jenkins环境
Docker-compose构建jenkins环境
1、创建docker在主机的jenkins数据映射目录
mkdir -p /data/jenkins_home
chown -R 1000 /data/jenkins_home
2、用docker-compose安装,当然你也可以用docker run的方式,创建一个docker-jenkins-compose.yml文件。
version: "3" services: jenkins: image: jenkins/jenkins:lts ports: - 8080:8080 - 50000:50000 restart: "always" container_name: jenkins environment: JAVA_OPTS: -Duser.timezone=Asia/Shanghai volumes: - /opt/jenkins/home:/var/jenkins_home - /var/run/docker.sock:/var/run/docker.sock - /usr/bin/docker:/usr/bin/docker privileged: true user: root
3、启动Jenkins容器
docker-compose -f docker-jenkins-compose.yml up -d
4、浏览器访问http://IP:8080
![](https://img2020.cnblogs.com/blog/2139106/202107/2139106-20210715153139488-2020400294.png)
——>
[root@sunli-tets ~]# cat /opt/jenkins/home/secrets/initialAdminPassword
22da82a375e14aae95ac8486ea848d81
![](https://img2020.cnblogs.com/blog/2139106/202107/2139106-20210715153139589-1265307440.png)
——>
![](https://img2020.cnblogs.com/blog/2139106/202107/2139106-20210715153139488-733016635.png)
——>
![](https://img2020.cnblogs.com/blog/2139106/202107/2139106-20210715153139511-60196266.png)