1

I am trying to pass an .obj file on my computer to a docker file then ADD it to the image, but I am getting a file not found error. The file I am trying to access is even in the same folder as the dockerfile, but that may not always be the case.

After running this command...

sh maya-pipeline.sh /Users/kromah/Documents/Developer/Github/Unity/unity-pipeline-maya/house_data/0004d52d1aeeb8ae6de39d6bd993e992/main.obj

maya-pipeline.sh

echo $1
docker build --build-arg house=$1 -t dock .

The echo command outputs the file location

Dockerfile

FROM mottosso/mayabase-centos

MAINTAINER [email protected]


ARG house=/house_data/0004d52d1aeeb8ae6de39d6bd993e992/main.obj
ADD $house /root/pipeline

Error Message

lstat Users/kromah/Documents/Developer/Github/Unity/unity-pipeline-maya/house_data/0004d52d1aeeb8ae6de39d6bd993e992/main.obj: no such file or directory
1
  • the lstat errors does not show the '/' as if you entered the path without specifying the root directory. - Edit: nvm I know what is wrong, I make an answer now. Commented Jul 13, 2017 at 0:24

2 Answers 2

4

Docker does not allow you to ADD files out of where the Dockerfile sits (outside the current Dockerfile's directory or its subdirectories).

Docker's dev team say this is for "security reasons" : by not allowing this, it avoids malicious Dockerfiles to try to import your precious /etc/passwd or shadow files, or others ;-)

So basically, any path not starting with the root directory of your Dockerfile cannot be added within the container, neither with ADD nor COPY.

Note that symlinks wont work better.

Sign up to request clarification or add additional context in comments.

Comments

0

I workaround is cp the file to the directory the Dockerfike is in.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.