I have a simple docker file for a test django application. I am running docker-compose as root user and I can read the requirements.txt file, but docker is erroring out. Any advice?
root@testdeploy:/app/test-project# docker-compose build
db uses an image, skipping
Building web...
Step 0 : FROM python:2.7
---> 93d77aec17a0
Step 1 : ENV PYTHONUNBUFFERED 1
---> Using cache
---> 25e2164606e7
Step 2 : WORKDIR /app/test-project/
---> Using cache
---> 366c21333f1f
Step 3 : RUN pip install -r /app/test-project/requirements.txt
---> Running in 75599e289c5e
Could not open requirements file: [Errno 2] No such file or directory: '/app/test-project/requirements.txt'
Service 'web' failed to build: The command [/bin/sh -c pip install -r /app/test-project/requirements.txt] returned a non-zero code: 1
Reading the file from command line.
root@testdeploy:/app/test-project# head -5 /app/test-project/requirements.txt
Cheetah==2.4.4
Django==1.7
Landscape-Client==14.01
PAM==0.4.2
Pillow==2.6.1
My docker file.
FROM python:2.7
ENV PYTHONUNBUFFERED 1
WORKDIR /app/test-project/
RUN pip install -r /app/test-project/requirements.txt
ADD . /app/test_project/
The docker build executes in a container separate from your host. The container has its own filesystem and is unaware of files on the host system.
You may copy files to the container by using
COPY /path/on/host /path/on/container
in the
Dockerfile
Currently pip needs files, but they have not been added.
In your case, you can move the
ADD
line at the bottom to before the pip command. It would also be better practice to useCOPY
, but that is not the bug.Like this:
If that still doesn't work, you need to adjust
.
to be the correct /path/to/test-project on the host.