[英]File not found from Dockerfile, docker-compose
I have these codes in my Dockerfile. 我的Dockerfile中有这些代码。
FROM python:3
# Create user named "airport".
RUN adduser --disabled-password --gecos "" airport
# Login as the newly created "airport" user.
RUN su - airport
# Change working directory.
WORKDIR /home/airport/mount_point/
# Install Python packages at system-wide level.
RUN pip install -r requirements.txt
# Make sure to migrate all static files to the root of the project.
RUN python manage.py collectstatic --noinput
# This utility.sh script is used to reset the project environment. This includes
# removing unecessary .pyc and __pycache__ folders. This is optional and not
# necessary, I just prefer to have my environment clean before Docking.
RUN utility_scripts/utility.sh
When I called docker-compose build
it returns /bin/sh: 1: requirements.txt: not found
. 当我调用
docker-compose build
它返回/bin/sh: 1: requirements.txt: not found
。 Despite I have load the necessary volume in my docker-compose.yml. 尽管我已经在docker-compose.yml中加载了必要的卷。 I am sure that requirements.txt is in
./
我确定
./
位于./
web:
build:
context: ./
dockerfile: Dockerfile
command: /home/airport/mount_point/start_web.sh
container_name: django_airport
expose:
- "8080"
volumes:
- ./:/home/airport/mount_point/
- ./timezone:/etc/timezone
How can I solve this problem? 我怎么解决这个问题?
Before running RUN pip install -r requirements.txt
, you need to add the requirements.txt file to the image. 在运行
RUN pip install -r requirements.txt
,您需要将requirements.txt文件添加到映像中。
...
ADD requirements.txt requirements.txt
RUN pip install -r requirements.txt
...
For a sample on how to dockerize a django application, check https://docs.docker.com/compose/django/ . 有关如何对Django应用程序进行docker化的示例,请查看https://docs.docker.com/compose/django/ 。 You need to add the requirements.txt and the code to the image.
您需要在图像中添加requirements.txt和代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.