My docker-compose.yml
:
version: '3.8'
services:
web:
build: ./app
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- ./app/:/usr/src/app/
ports:
- 8000:8000
env_file:
- .dev.env
my Dockerfile
in ./app
:
FROM kuralabs/python3-dev
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip3 install -r requirements.txt
COPY . .
My file .dev.env
:
ALLOWED_HOSTS='localhost 127.0.0.1'
DEBUG=1
SECRET_KEY='django-insecure-...'
I run the project with the commands:
$docker-compose build
$docker-compose up -d
I get variables in settings.py
:
load_dotenv()
print(f'Environment: {os.environ}')
my variables from the '.dev.env' file are not in the list of environment variables.
Please help me understand why .dev.env
variables don't get into the environment.