1.创建⼀个jenkins的Dockerfile
mkdir tomcat
cd tomcat
2、上传需要的安装包
apache-tomcat-8.5.47.tar.gz
jdk-8u211-linux-x64.tar.gz
jenkins.war
3、编写Dockerfile
vim Dockerfile
# This my first jenkins Dockerfile
# Version 1.0
FROM centos:7
MAINTAINER [email protected]
ENV JAVA_HOME /usr/local/jdk-11.0.16
ENV TOMCAT_HOME /usr/local/apache-tomcat-9.0.79
ENV PATH=$JAVA_HOME/bin:$PATH
ADD apache-tomcat-9.0.79.tar.gz /usr/local/
ADD jdk-11.0.16_linux-x64_bin.tar.gz /usr/local/
RUN rm -rf /usr/local/apache-tomcat-9.0.79/webapps/*
ADD jenkins.war /usr/local/apache-tomcat-9.0.79/webapps
RUN rm -rf apache-tomcat-9.0.79.tar.gz jdk-11.0.16_linux-x64_bin.tar.gz
RUN yum install fontconfig -y
EXPOSE 8080
ENTRYPOINT ["/usr/local/apache-tomcat-9.0.79/bin/catalina.sh","run"]
FROM centos:7镜像--------->配置了阿里云镜像
4、创建镜像 jenkins:v1(自定义名称)
docker build -t jenkins:v1 .
5、docker images(查看所有镜像),Jenkins:v1构建成功
6、运行jenkins:v1
-d(后台运行) --name(自定义名称) -p(端口映射)
docker run -itd --name jenkins1 -p 8081:8080 jenkins:v1