0

I have created a docker file with the following:

    FROM python:3.9.2
MAINTAINER KSMC
RUN apt-get update -y && apt-get install -y python3-pip python-dev

WORKDIR /Users/rba/Documents/Projects/DD/DD-N4

RUN pip3 install -r requirements.txt

ENTRYPOINT ["python3"]
CMD ["main.py"]

My python code is in main.py , my python version is 3.9.2 and all my python code, requirements.txt and docker file are in the location /Users/rba/Documents/Projects/DD/DD-N4. Upon trying to create docker image using:

docker build -t ddn4image .

I am getting the following error:

#8 1.547 ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' ------ executor failed running [/bin/sh -c pip3 install -r requirements.txt]: exit code: 1

Can someone point out what is causing this?

1 Answer 1

2

You forgot to do a COPY statement.

Before you run RUN pip3 install -r requirements.txt, just put the following line

COPY . .

You need to do this because your local files need to be copied into the docker image build, so when your container is created, the files will exists on it.

Read the docs about COPY at docker docs.

Hint

Remove the ENTRYPOINT statement and use

CMD ["python3", "main.py"]

Here it is a good explanation about ENTRYPOINT and CMD difference.

Sign up to request clarification or add additional context in comments.

5 Comments

Upon making changes per your suggestion, I am getting the following error for pip still:
This is the error I am gettiing: executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
I saw that are you running as pip, did you tried as pip3?
I tried using both. There seemed to be some incompatibility with pyodbc on the requirement.txt. It ran fine when I removed the pyodbc from requirements.txt.
Right, see if this question helps you about the pyodbc problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.