[英]File not found from Dockerfile, docker-compose
我的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
当我调用docker-compose build
它返回/bin/sh: 1: requirements.txt: not found
。 尽管我已经在docker-compose.yml中加载了必要的卷。 我确定./
位于./
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
我怎么解决这个问题?
在运行RUN pip install -r requirements.txt
,您需要将requirements.txt文件添加到映像中。
...
ADD requirements.txt requirements.txt
RUN pip install -r requirements.txt
...
有关如何对Django应用程序进行docker化的示例,请查看https://docs.docker.com/compose/django/ 。 您需要在图像中添加requirements.txt和代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.