以下是我的DockerFile
在Jenkins中使用docker-build-step构建此文件时,构建会在ADD处失败,并抛出以下异常。
FROM centos:centos6
MAINTAINER Priyanka
################## Helpful utils
RUN yum -y install sudo
RUN yum -y install curl
RUN yum -y install unzip
################## JDK7
#Note that ADD uncompresses this tarball automatically
ADD jdk-7u79-linux-x64.tar.gz /opt
WORKDIR /opt/jdk1.7.0_79
RUN alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 1
RUN alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 1
RUN alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 1
RUN echo "JAVA_HOME=/opt/jdk1.7.0_79" >> /etc/environment
ENV JAVA_OPTS -Xms1024m -Xmx4196m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m
################## TOMCAT
#Note that ADD uncompresses this tarball automatically
ADD apache-tomcat-7.0.67.tar.gz /usr/share
WORKDIR /usr/share/
RUN mv apache-tomcat-7.0.67 tomcat7
RUN echo "JAVA_HOME=/opt/jdk1.7.0_79/" >> /etc/default/tomcat7
RUN groupadd tomcat
RUN useradd -s /bin/bash -g tomcat tomcat
RUN chown -Rf tomcat.tomcat /usr/share/tomcat7
EXPOSE 8087
################## ROC Client War Download
RUN curl -O http://10.113.57.164:8080/job/ROC4.0_Client/ws/spark-web/entrypoint/target/entrypoint.war
RUN unzip entrypoint.war -d /usr/share/tomcat7/webapps/roc_client
ADD validation-api-1.1.0.Final.jar /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/
ADD validation-api-1.1.0.Final-sources.jar /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/
RUN rm /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/validation-api-1.0.0.GA-sources.jar
RUN rm /usr/share/tomcat7/webapps/roc_client/WEB-INF/lib/validation-api-1.0.0.GA.jar
################## Tomcat launch
CMD ["/usr/share/tomcat7/bin/catalina.sh","run"]
在Jenkins中使用docker-build-step构建此文件时,构建会在ADD处失败,并抛出以下异常。
Step 0 : FROM centos:centos6
---> 3bbbf0aca359
Step 1 : MAINTAINER Priyanka
---> Using cache
---> c8055ba8439a
Step 2 : RUN yum -y install sudo
---> Using cache
---> 203da82ad2af
Step 3 : RUN yum -y install curl
---> Using cache
---> c6cb08257236
Step 4 : RUN yum -y install unzip
---> Using cache
---> 688620db641a
Step 5 : ADD jdk-7u79-linux-x64.tar.gz /opt
ERROR: Build step failed with exception
java.lang.RuntimeException: java.lang.ClassCastException: org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl cannot be cast to javax.json.JsonString
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand.execute(CreateImageCommand.java:139)
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:75)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: java.lang.ClassCastException: org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl cannot be cast to javax.json.JsonString
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonString(JsonObjectBuilderImpl.java:194)
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getString(JsonObjectBuilderImpl.java:199)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand$1.callback(CreateImageCommand.java:123)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand.readJsonStream(CreateImageCommand.java:161)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateImageCommand.execute(CreateImageCommand.java:115)
... 10 more
Build step 'Execute Docker command' marked build as failure
Finished: FAILURE
我已经运行了这个构建多次,没有任何问题的成功完成。我对构建配置进行了一些临时更改并恢复了原状。从那时起,它就会抛出此错误。我尝试删除文件中的所有docker命令,仅保留一个RUN命令。仍然存在相同的问题。它无法运行任何docker命令。
docker build --no-cache
)。 - VonCRUN
命令,并使用一个单独的RUN
命令执行不同的安装(utils、JDK7、TOMCAT),从而减少层数,进而减少所需的磁盘空间。可以参考这里的一些示例:https://github.com/jfrazelle/dockerfiles - Auzias