0

I am trying to copy files in Dockerfile.

Here is how my folder looks like.

main.R <- my main executable file
app <- folder with Dockerfile.

In Dockerfile I have the following commands:

RUN mkdir -p ~/application
COPY "../" "application/"
WORKDIR "application/" 
ENTRYPOINT ["Rscript", "main.R"]

This does not work, it gives me error `Fatal error: cannot open file 'main.R': No such file or directory

If I move main.R file inside app folder everything works fine. How can I make it work without moving files.

user1700890
  • 7,144
  • 18
  • 87
  • 183
  • From the directory up, run `docker build -f app/Dockerfile .`; the `COPY` path will be relative to that parent directory, so you can change it to `COPY ./ application/`, and not be copying things from outside the context directory. – David Maze Dec 14 '20 at 22:37
  • @DavidMaze Thank you so much. I am doing it in Azure and in YAML file I have variable set `dockerfilePath: '$(Build.SourcesDirectory)/app/Dockerfile'` and later it use like this `dockerfile: $(dockerfilePath)`. I am guessing it should set proper context, but it is not working. – user1700890 Dec 14 '20 at 22:47

0 Answers0