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?
Since
-f
caused another problem, I developed another solution.The
-f
flag does not solved my problem because myonbuild
image looks for a file in a folder and had to call like this:-f foo/bar/Dockerfile foo/bar
instead of
-f foo/bar/Dockerfile .
Also note that this is only solution for some cases as
-f
flagThe solution for those who use composer is to use a volume pointing to the parent folder:
But I'm pretty sure the can be done playing with volumes in Dockerfile.
Unfortunately, (for practical and security reasons I guess), if you want to add/copy local content, it must be located under the same root path than the
Dockerfile
.From the documentation:
EDIT: There's now an option (
-f
) to set the path of your Dockerfile ; it can be used to achieve what you want, see @Boedy 's response nelow.With docker-compose you could set context folder:
You can build the Dockerfile from the parent directory: