I have a setup of the docker-compose.production.yml
in this way:
services:
web:
build: .
command: uvicorn main:app --host ${HOST} --port ${PORT}
ports:
- "${PORT}:${PORT}"
env_file:
- .env.production
environment:
- APP_NAME=${APP_NAME}
- ENVIRONMENT=${ENVIRONMENT}
- HOST=${HOST}
- PORT=${PORT}
- DEBUG=${DEBUG}
and i have setup the .env.production
as:
APP_NAME=FastAPI App Production
ENVIRONMENT=production
HOST=0.0.0.0
PORT=8000
DEBUG=false
and while trying to run:
docker-compose -f docker-compose.production.yml up --build
I am getting the error as:
docker-compose -f docker-compose.production.yml up –build
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “HOST” variable is not set. Defaulting >to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “PORT” variable is not set. Defaulting >to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “PORT” variable is not set. Defaulting to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “PORT” variable is not set. Defaulting to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “APP_NAME” variable is not set. Defaulting to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “ENVIRONMENT” variable is not set. Defaulting to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “HOST” variable is not set. Defaulting to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “PORT” variable is not set. Defaulting to a blank string.”
time=”2024-08-17T18:58:24+05:45″ level=warning msg=”The “DEBUG” variable is not set. Defaulting to a blank string.”
no port specified: :
However when I specify the environment file directly in the command, it is working.
docker-compose --env-file .env.production -f docker-compose.production.yml up --build