Docker Community Forums

Share and learn in the Docker community.

Could not open requirements file


(Armandb) #1

Hi guys,

I am new to Docker and I am trying to build a Python image with the libraries I need. I tried to follow some tutorials online but I did not succeed.

Here is what my docker file looks like. I placed requirements.txt just next to Dockerfile in the same directory.

FROM python:latest
RUN apt-get updat
RUN apt-get install cron -yqq curl
RUN pip install -r requirements.txt
RUN mkdir /data
RUN mkdir /notebooks
RUN mkdir /tmp/tflearn_logs
VOLUME ["/data", “/notebooks”, “/tmp/tflearn_logs”]
EXPOSE 8888
CMD jupyter notebook --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token=‘demo’

However when I try to build the image it says “Could not open requirements file: [Errno 2] No such file or directory: ‘requirements.txt’”.

Does someone know how to fix my problem ? Or/and has any remark about something useless I do or something useful I forgot in my Dockerfile ?

Thanks for the help

Armand


(David Maze) #2

Nothing in your Dockerfile COPYs any of your source files into the built image (or ADDs an sdist).


(Armandb) #3

Ok I managed to build the image after copying the requirements.txt file into the image. Thanks for your help.


(Siju Oommen George) #4

You need to keep the requirements.text inside the image because pip looks inside the image

Add the following

COPY requirements.txt /tmp
WORKDIR /tmp
RUN pip install -r requirements.txt

Let me know if it is fixed :slight_smile:
–Siju


(Armandb) #5

Yes it worked fine! Thanks for the help!


(Ethanlokesh) #6

It worked for me. Thanks


(Xcodemaker) #7

thanks.it worked for me