docker

Docker: adding a file from a parent directory


In my Dockerfile I've got :

ADD ../../myapp.war /opt/tomcat7/webapps/

That file exists as ls ../../myapp.war returns me the correct file but when I execute sudo docker build -t myapp . I've got :

Step 1 : ADD ../../myapp.war /opt/tomcat7/webapps/
2014/07/02 19:18:09 ../../myapp.war: no such file or directory

Does somebody know why and how to do it correctly?


Solution

    1. cd to your parent directory instead
    2. build the image from the parent directory, specifying the path to your Dockerfile
    docker build -t <some tag> -f <dir/dir/Dockerfile> .
    

    In this case, the context of the docker will be switched to the parent directory and accessible for ADD and COPY