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

  • Copy folder with wildcard from docker container to host
  • Symfony app/console command is not running with cronjob inside Docker container
  • Running and debugging tests in a Docker container
  • Docker in Windows is mounting files as directories
  • How to we login to docker hub(private registry) using chef recipe?
  • (Windows Git-bash) IntelliJ git bash shell color scheme messed up with Docker
  •     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 SSL connection error
  • Docker container doesn't start due to CMD and ENTRYPOINT
  • Rename a project by keeping containers
  • How to set the “current” directory of a Dockerfile with Docker Compose?
  • docker-compose build throwing error ERROR: Untar re-exec error: signal: killed: output:
  • Com.github.dockerjava.api.exception.DockerClientException: Certificate path (DOCKER_CERT_PATH) ‘/root/.docker/certs’ doesn’t exist General Discussions
  • 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.