How can I build a docker image with it parent folder as workdir?

This probably is a dumb question, but I'm newbie in Docker and I'm struggle with this. I have a project with many subfolders, like the example below:

project-folder:
       folder_1:
           code1.py
           Dockerfile
           requirements.txt
       folder_2:
           code2.py
           Dockerfile
           requirements.txt
       folder_data:
           file1
           file2
           file3

Then, I would like to do this:

  1. Maintain my workdir in project-folder for all containers;
  2. Inside each container, I should be able to access the folder_data - I know that I have to specify a volume, I just don't know how to do this without keep my project-folder as workdir;
  3. I need to pass my workdir (project-folder) to my code1.py

Note: my image was created successfully only when I create it within each subfolder, like this Dockerfile:

FROM python:3.6-slim
COPY . /folder_1
WORKDIR /folder_1
RUN pip install -r requirements.txt
CMD ["python3", "code1.py", "$(pwd)"]

Image creation comand:

docker build -t image_folder1 .

I am currently creating the image in the context of folder_1, because I was unable to create the image correctly in the context of the project-folder



from Recent Questions - Stack Overflow https://ift.tt/3pWECfb
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations