docker error WARN[0000] The "DB_USER" variable is not set. Defaulting to a blank string

Error en docker-compose down: WARN[0000] The "DB_USER" variable is not set. Defaulting to a blank string

Al ejecutar el siguiente comando: docker-compose -f docker-compose.yml down que elimina todos los contenedores definidos en el archivo docker-compose.yml. Una parte de este fichero tiene las siguientes lineas: # docker-compose.yml hostname: db container_name: php-maria-db build: context: docker/mariadb args: - DB_USER=${DB_USER} - DB_PASSWORD=${DB_PASSWORD} environment: TZ: ${TIME_ZONE} MYSQL_USER: ${DB_USER} MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} volumes: ... Al no existir la definición de las variables de entorno DB_USER, DB_PASSWORD entre otras lanza el error: WARN[0000] The "xxx" variable is not set. Defaulting to a blank string

Ejemplo error WARN[0000] The xxx variable is not set. Defaulting to a blank string
Ejemplo error WARN[0000] The xxx variable is not set. Defaulting to a blank string
Esto sucede porque en la linea me faltaba incluir el fichero de variables de entorno .env mediante el parámetro --env-file de esta forma: docker-compose --env-file ./docker/.env -f docker-compose.yml down
Ejemplo resultado comando docker-compose con --env-file
Ejemplo resultado comando docker-compose con --env-file

Autor: Eduardo A. F.
Publicado: 26-10-2021 19:57