1

I have the following dockerfile snippet:

RUN mkdir sys_libs
COPY sys_lib/vs_log.rb sys_libs/vs_log.rb

The file does exist in the local ./sys_lib folder.

when I attempt to build: get:

COPY failed: stat /var/lib/docker/tmp/docker-builder085599896/sys_lib/vs_log.rb: no such file or directory

Note the folder name referenced in the docker path is the name of the local folder, not the name of the docker folder just created.

I get the same if I do a COPY sys_lib/ sys_libs/

If I make the local and the docker folder the same I get the same thing:

RUN mkdir sys_lib
COPY sys_lib/ sys_lib/

I have tried it with leading./ and without on both sides.

I am out of options. Any ideas?

whoan
  • 8,143
  • 4
  • 39
  • 48
Donald French
  • 1,731
  • 1
  • 17
  • 30
  • 1
    I am almost sure you are ignoring `sys_lib` (local) in your .dockerignore file (a.k.a. the folder is not part of the *context*). – whoan Sep 11 '18 at 01:47
  • I currently have no .dockerignore file, so that is not the cause. Also why would it be referencing the local file associated with the temp image being created? – Donald French Sep 11 '18 at 02:15
  • Could you show me the command you are using to build? Maybe you using a wrong context. – whoan Sep 11 '18 at 02:38
  • And regarding your question about the file referenced, */var/lib/docker/tmp/docker-builder085599896* is the context the docker daemon created to build the image. As we can see, the folder *sys_lib* was not sent to the context, or it is in another path. – whoan Sep 11 '18 at 02:40
  • docker build -t dhf0820/delivery-manager:latest -f ./delivery-manager/Dockerfile ./delivery-manager the source folders have the ./sys_lib in it at the level the docker is being run. The main app is and most of the code is in the delivery-manager folder that contains the docker file. This is part of several processes that have man common libs and they are one level up (current folder) ./sys_lib The real docker folder is also called sys_lib. I changed the name temporarily to see which was being referenced. I get the same error if named properly. – Donald French Sep 11 '18 at 02:44
  • Ok, you are telling docker your context is `./delivery-manager`. Does `sys_lib/` exist in `./sys_lib/` or `./delivery-manager/sys_lib/`? – whoan Sep 11 '18 at 02:48
  • It resides in ./sys_lib since it is used by several process that ar4e being created. The current directory has several other source folders line delivery-manager. – Donald French Sep 11 '18 at 02:50
  • OK, I understand, but in that case the folder is out of the context. That is the problem... – whoan Sep 11 '18 at 02:51
  • is not the context the folder where the build is run from. I tried running it from the delivery-manager and of course, it failed with out of context error. If I am doing it wrong, how do I generate the image with a common folder one level up from the main folder? – Donald French Sep 11 '18 at 02:53
  • No, it is not, it is what you specify as the last argument in the `docker build` command. – whoan Sep 11 '18 at 02:55
  • In this case, what is the proper command and where is it executed from – Donald French Sep 11 '18 at 02:57
  • I got the "proper" way that I followed from several sites like this: https://www.jamestharpe.com/include-files-outside-docker-build-context/ – Donald French Sep 11 '18 at 03:03

0 Answers0