以下是我的DockerFile
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命令。
答案 0 :(得分:0)
我遇到了同样的问题。实际上,您要查找的文件不存在于工作区作业目录中。如果您的docker-step-plugin可以找到该文件,那么来自您的Dockerfile的命令ADD将起作用:-) 希望这有帮助。
答案 1 :(得分:0)
我知道这是相当陈旧的,但我遇到了这个问题并找到了一个不同的解决方案,可以帮助将来发现这个问题的其他人。
在我的情况下,我使用devicemapper作为存储驱动程序,并且包含thinpool的逻辑卷已经达到90%已满,此时它会在尝试创建新图像时触发警报。这导致Jenkins Docker插件失败,上面发布了相同的堆栈跟踪。
从图像存储中删除旧图像解决了问题。