[Install Jenkins] #Install
参考:https://github.com/jenkinsci/docker/blob/master/README.md
mkdir -p /mydata/jenkins
version: '3'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
restart: always
user: root
ports:
- 8090:8080
volumes:
- /mydata/jenkins:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
其中下述配置仅当在Jenkins容器内调用host的docker命令时需要配置
user: root
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
- /usr/lib64/libltdl.so.7:/usr/lib/x86_64-linux-gnu/libltdl.so.7
docker-compose up -d
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|-->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
安装Jenkins的docker-compose.yml中已支持调用host的docker命令。但为了在Jenkins中可以使用私有镜像仓库,需要在Jenkins运行的容器中再次执行docker login命令
docker exec -i -t container_id /bin/bash
docker login -u 'user' -p 'password' example.myregistry.com