0

I am trying to create an image using a dockerfile. As I saw from public repositories, People have a directory named docker. So I want to copy all my code (basicaly whole repo) into docker image. But I couldn't find the proper way. (You can see the basic file structure below.)

Directory Structure

enter image description here

So there are two main questions:

1- How can I copy all files and directories from one level above?

2- Is this approach acceptable as best practice?

Here is the docker file I have at the moment.

#This file is named as dockerfile
FROM continuumio/miniconda3
COPY . . #This line is probably faulty.
ADD environment.yml ./

RUN conda env create -f environment.yml
ENTRYPOINT [ "python","test.py"]
OzerT
  • 43
  • 7
  • Also see [How to include files outside of Docker's build context?](https://stackoverflow.com/questions/27068596/how-to-include-files-outside-of-dockers-build-context): you have to run `docker build .` from the topmost `my_repo` directory and `COPY` paths will always be relative to that directory, even if you choose to put the Dockerfile somewhere else. – David Maze Sep 21 '21 at 11:12

1 Answers1

2

It depends from where you call the docker build command. If you're in the my_repo directory, you could call

docker build -f .\docker\Dockerfile .

With the final . you define the current directory as your build context and in this case the COPY command will copy all the files into the container.

EDIT: However, for easier handling and readability, I would place the Dockerfile at the level of my_repo

ddegasperi
  • 662
  • 9
  • 12