jenkins的docker自定義鏡像

下載openjdk, maven 等到目錄中。linux

#Dockerfile
FROM jenkins/jenkins:lts-centos
ENV JDK=openjdk-13.0.2_linux-x64_bin.tar.gz
ENV MAVEN=apache-maven-3.6.3-bin.tar.gz

# copy the jdk  archive to the image,and it will automaticlly unzip the tar file
ADD ${JDK} /opt/
ADD ${MAVEN} /opt/
ADD hudson.model.UpdateCenter.xml /var/jenkins_home/hudson.model.UpdateCenter.xml

# use root
USER root

建立hudson.model.UpdateCenter.xml 。國內或許須要此文件,解決有可能會第一次啓動jenkins很慢很慢。docker

<?xml version='1.1' encoding='UTF-8'?>
<sites>
  <site>
    <id>default</id>
    <url>http://mirror.xmission.com/jenkins/updates/update-center.json</url>
  </site>
</sites>

build jenkins 自定義鏡像apache

docker build . -t my/jenkins

開啓自定義的jenkins, 把本機的docker暴露給容器 json

docker run -d \
--name jenkins-docker \
-p8080:8080 \
--privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /bin/docker:/bin/docker \
-v /usr/local/bin/docker-compose:/bin/docker-compose \
my/jenkins

 如須要jenkins的鏡像加速,進入jenkins容器中。參考 http://www.javashuo.com/article/p-abwlnone-gr.htmlcentos

echo "127.0.0.1 mirrors.jenkins-ci.org" >> /etc/hosts
相關文章
相關標籤/搜索