Dockerfile – 挂载主机目录 – 复制目标并运行 – 错误

请在docker文件内容下面find –

FROM centostaryum MAINTAINER karthik.jayaraman VOLUME ["/DockerFiles/Tomcat/tar"] ADD /tar/apache-tomcat-7.0.47.tar.gz /tmp RUN ls /tmp RUN tar -tzf /tmp/apache-tomcat-7.0.47.tar.gz -C /opt EXPOSE 8080 CMD service tomcat7 start 

它给了我以下错误

  Step 0 : FROM centostaryum ---> 175c30b6dbd7 Step 1 : MAINTAINER karthik.jayaraman ---> Running in 8872c0c61735 ---> d16323a6931a Removing intermediate container 8872c0c61735 Step 2 : VOLUME ["/DockerFiles/Tomcat/tar"] ---> Running in 829a35f36b3f ---> 74314abbc28e Removing intermediate container 829a35f36b3f Step 3 : ADD /tar/apache-tomcat-7.0.47.tar.gz /tmp ---> 07a0bc6713ab Removing intermediate container 3af17fba511a Step 4 : RUN ls /tmp ---> Running in 113ed759c156 apache-tomcat-7.0.47 ---> 6fd41ed2fb76 Removing intermediate container 113ed759c156 Step 5 : RUN tar -tzf /tmp/apache-tomcat-7.0.47.tar.gz -C /opt ---> Running in 08e4d0a1f30a tar (child): /tmp/apache-tomcat-7.0.47.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now 2014/06/13 18:25:32 The command [/bin/sh -c tar -tzf /tmp/apache-tomcat-7.0.47.tar.gz -C /opt] returned a non- zero code: 2 

从容器中的临时目录列表命令列出了tomcat文件,但我不知道什么是错误的tar命令。

我希望在解决这个问题上有所帮助。 谢谢。

根据ADD命令的文档 :

如果是以可识别的压缩格式(身份,gzip,bzip2或xz)的本地tar归档文件,则将其解压缩为目录。 来自远程URL的资源不被解压缩。 当一个目录被拷贝或解压时,它和tar -x具有相同的行为:结果是下面的联合:

  • 无论在目的地的path和
  • 源代码树的内容,解决冲突,赞成“2”。 在逐个文件的基础上。

你可以直接将文件添加到/opt ,它会做你想做的。 更明确地说,就是这样做:

ADD /tar/apache-tomcat-7.0.47.tar.gz /opt

RUN yum -y update && yum -y install wget && yum install -y tar.x86_64 && yum clean all