version: "3.9"
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins:lts
user: root
ports:
- 8888:8080
- 50001:50000
restart: "always"
volumes:
- ./jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
container_name: jenkins
容器名称为:jenkinsimage: jenkins/jenkins:lts
使用 镜像为jenkins/jenkins:lts稳定版本ports
端口映射,如8888:8080 将宿主机的8888端口映射到容器的8080端口,访问宿主机的8888端口,即可映射到容器内8080volumes
:挂在卷
docker-compose up -d
启动jenkins容器,-d表示后台启动