I am trying to run docker-compose up
with the following configuration:
php:
image: php:7.0-fpm
expose:
- 9000
links:
- nginx
nginx:
env_file: .env
image: nginx:latest
ports:
- 80:80
- 433:433
environment:
- NGINX_HOST: ${APP_URL}
mysql:
env_file: .env
image: mysql:latest
ports:
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
- MYSQL_DATABASE: ${DB_DATABASE}
- MYSQL_USER: ${DB_USERNAME}
- MYSQL_PASSWORD: ${DB_PASSWORD}
- MYSQL_ALLOW_EMPTY_PASSWORD: no
I have an .env
file in the same directory and am able to test the variable in the shell, but docker doesn't seem to load the .env
.
WARNING: The APP_URL variable is not set. Defaulting to a blank string.
WARNING: The DB_PASSWORD variable is not set. Defaulting to a blank string.
WARNING: The DB_DATABASE variable is not set. Defaulting to a blank string.
WARNING: The DB_USERNAME variable is not set. Defaulting to a blank string.
ERROR: Validation failed in file './docker-compose.yaml'
UPDATE
I just changed the env_file
value to point to a non-existing file and no errors are thrown. It seems like docker is completely ignoring the option.
Like many other version related issues, updating to v1.7.1 of docker-compose resolved the issue, works like a charm!
I got this issue because I wasn't running $docker-compose up
from the same directory as my .env
and docker-compose.yml
file. The command can still find the docker-compose.yml
file, through a search, but it doesn't also search that location for the .env
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With