Dockerfile – Mount host directory – copy a tar fie and run it – Error

Please find below the docker file contents –

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

It gives me the following error

  • Mounting AWS EBS volume when launching VM with Docker Machine
  • ADD/COPY files with sbt-native-packager's docker support
  • Docker: Unable to execute RUN command after ADD when starting from scratch
  • Connect to DynamoDB Local from inside docker container with boto3
  • How do i migrate mysql data directory in docker container?
  • regenerating certificates hangs on windows 7
  •     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
         ---> 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

    The list command from the temp directory in the container lists the tomcat file but i am not sure what is wrong with the tar command.

    I would appreciate some help in figuring out this issue. Thanks.

  • GitLab CI review enviroment with docker
  • docker: command not found with Jenkins build and publish plugin on Mac
  • How do I run a salt state on a running docker container
  • Mounting ISO images with powershell inside windowsservercore fails
  • Docker container not showing volume mounted - Access issue
  • Connect many Jenkins servers with different branches of the same github repo
  • 2 Solutions collect form web for “Dockerfile – Mount host directory – copy a tar fie and run it – Error”

    Per the documentation on the ADD command:

    If is a local tar archive in a recognized compression format
    (identity, gzip, bzip2 or xz) then it is unpacked as a directory.
    Resources from remote URLs are not decompressed. When a directory is
    copied or unpacked, it has the same behavior as tar -x: the result is
    the union of:

    • whatever existed at the destination path and
    • the contents of the source tree, with conflicts resolved in favor of “2.” on a
      file-by-file basis.

    You can just ADD the file to /opt directly and it will do what you want. More explicitly, just do this:

    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

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.