1

I am attempting to modify a Dockerfile that includes code like this:

ARG FILE_SOURCE_DIR

ADD ${FILE_SOURCE_DIR}/check-md5.sh /download/
ADD ${FILE_SOURCE_DIR}/app /app/
ADD ${FILE_SOURCE_DIR}/R/JRI.jar /download/
ADD ${FILE_SOURCE_DIR}/R/JRIEngine.jar /download/
ADD ${FILE_SOURCE_DIR}/R/REngine.jar /download/

My build environment looks like this:

   \downloads
   \images
       \kafka
           Dockerfile

I would like to pass in FILE_SOURCE_DIR as a relative path (per the documentation) but I can't get the syntax right - no matter what I try I get an error similar to:

 ADD failed: stat /var/lib/docker/tmp/docker-builder187920988/downloads/check-md5.sh: no such file or directory

Sometimes I get this:

ADD failed: Forbidden path outside the build context: ../../downloads/check-md5.sh ()

I know that the path has to be relative to the context directory but as I said, nothing I try seems to work:

"../../downloads"
"..\..\downloads"
"C:\path\downloads\"

Is the Docker ADD command limited to things inside the context? If so, how does one include the same file in multiple contexts?

user1071914
  • 3,295
  • 11
  • 50
  • 76
  • Just found this question.... https://stackoverflow.com/questions/27068596/how-to-include-files-outside-of-dockers-build-context?rq=1 – user1071914 Apr 03 '18 at 17:12
  • It looks like the only way to do this is to add the file from a remote HTTP:// URL. In our case, we wound up setting up a Tomcat instance and pulling the files from there. From the documentation: `If is a URL and does not end with a trailing slash, then a file is downloaded from the URL and copied to .` – user1071914 Apr 06 '18 at 19:02

2 Answers2

1

You can specify the Dockerfile outside the Kafka folder using -f.

docker build -t tag-name -f images/kafka/Dockerfile .

So that you can access the download folder

akhil krishna
  • 316
  • 1
  • 4
  • 14
0

ADD obeys the following rules:

The path must be inside the context of the build
...

From Dockerfile reference.

Yuankun
  • 6,875
  • 3
  • 32
  • 34