[英]Docker ERROR: Couldn't find env file: /home/sam/code/docker/.env.dev
I'm learning how to use docker with Django.我正在学习如何将 docker 与 Django 一起使用。 So first step is you setup the Dockerfile
and here's the content of the file.所以第一步是设置Dockerfile
,这是文件的内容。
FROM python:3.8.0-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt
# copy project
COPY . /usr/src/app/
another file the docker-compose.yml
file content below另一个文件docker-compose.yml
文件内容如下
version: '3.7'
services:
web:
build: ./project
command: python manage.py runserver 0.0.0.0:8000
volumes:
- ./project/:/usr/src/app/
ports:
- 8000:8000
env_file:
- ./.env.dev
now these two files are in the folder docker
which also has my django project folder called project
keeping it simple:)现在这两个文件位于docker
文件夹中,其中还有我的 django 项目文件夹,名为project
保持简单:)
When I run docker-compose build
I get back the error当我运行docker-compose build
时,我得到了错误
ERROR: Couldn't find env file: /home/sam/code/docker/.env.dev
You are specifying that.env file can be found in the location where your docker-compose.yml file is located.您正在指定 that.env 文件可以在 docker-compose.yml 文件所在的位置找到。
env_file:
- ./.env.dev
Make sure that your.env file is available there.确保 your.env 文件在那里可用。 If you don't need any environment variables to be set just remove above line from the docker-compose.yml file.如果您不需要设置任何环境变量,只需从 docker-compose.yml 文件中删除以上行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.