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

  • Optional container in task definition in cloudformation tempalte
  • How does the onbuild directory work for the offical Rails docker image?
  • Docker Named Volume location Mac
  • Docker DNS getaddrinfo ENOTFOUND
  • Ahow to use multiple terminals in the docker container?
  • 'sudo: no tty present and no askpass program specified' error?
  •     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
    

    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.

  • Tomcat datasource Properties with Docker and Jenkins
  • OS Container vs Application Container
  • How to allow my host IP address in the PostgreSQL pg_hba.conf file
  • Aurora scheduler doesn't start
  • java.lang.IllegalArgumentException starting libreplan in docker
  • Maintaining and supporting container base images
  • 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.