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

  • Is there any way to make sure you read line by line from docker-py logs when in stream mode?
  • How to specify --dns entry in docker swarm
  • How to get docker-compose to always re-create containers from fresh images?
  • My docker container has no internet
  • How to access docker logs of another container
  • Docker permission issue after copying files
  •     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.

  • docker notary : tls: oversized record received with length 20527
  • Push Docker Images to Google Cloud using Visual Studio Online
  • Docker - is it necessary to push images to remote server?
  • Docker not port forwarding correctly?
  • docker-compose - externalize spring
  • Docker installation debian openjdk-7-jre
  • 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.