Docker cannot find file when creating image

This is my Dockerfile

FROM python:3.6-slim

COPY app/ /app

EXPOSE 8000

RUN cd /app/
RUN pip install -r requirements.txt

WORKDIR /app/project/

RUN python manage.py makemigrations
RUN python manage.py migrate
RUN export DJANGO_SETTINGS_MODULE="project.settings"

CMD [ "python", "manage.py", "server"]

When I try to create it, it cannot say that it cannot find the requirements.txt file inside the application folder.

+4
source share
1 answer

When you do

RUN cd /app/
RUN pip install -r requirements.txt

Docker will go into / app / project and then go back to the previous folder and then the second command will fail. You should use it as follows:

RUN cd /app/ && pip install -r requirements.txt

EDIT : match comment

In addition, you must replace the export string with ENV, for example:

ENV DJANGO_SETTINGS_MODULE project.settings
+6
source

Source: https://habr.com/ru/post/1682500/


All Articles