0

Writing because I have a stranger problem with Docker File process

The problem is regarding Docker File Context. As far as I understood the directory context that I can access from Dockerfiles is one directory up and one directory down

Example Directory Tree

A - B - C - D - E

If my docketfile is on C I can access B D But I can’t access A E

I have a problem because this is my case

My Docker file is on C And I need to access files from B D E And I really don’t know how to do it

I need to access it Becaiuse my target jar is on E And I need to do an ADD to this file to implementing docket hot deploy with Spring Dev Tools

Somenthing like on Docker

ADD .\D\E\jar.file jar.file ENtrypoint xxx Expose xxx

And I still need to access B to get some other files.

Was Clear?

Sorry I know is strange

  • Possible duplicate of [How to include files outside of Docker's build context?](https://stackoverflow.com/questions/27068596/how-to-include-files-outside-of-dockers-build-context) – David Maze Sep 15 '19 at 11:26
  • You can only access files in and underneath the directory you pass to `docker build`, which is usually the directory containing the `Dockerfile` (but doesn't have to be). It is _not_ "one directory up"; you can't `COPY ../...`, and absolute paths get interpreted as though they started with `./` (relative to the build context). – David Maze Sep 15 '19 at 11:27

1 Answers1

0

If you can do something it does not mean it is right or if is something not recommended so it means the issue can arise.

If you read General guidelines and recommendations, It will recommend keeping the thing in context, then why you need to copy thing from the different drive? Btw it is not possible in Linux as docker need to copy from the context so better to keep your jar file in dockerfile context.

Understand build context

When you issue a docker build command, the current working directory is called the build context. By default, the Dockerfile is assumed to be located here, but you can specify a different location with the file flag (-f). Regardless of where the Dockerfile actually lives, all recursive contents of files and directories in the current directory are sent to the Docker daemon as the build context.

Adiii
  • 54,482
  • 7
  • 145
  • 148