Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose --env-file is not working at all

I'm trying this:

https://docs.docker.com/compose/environment-variables/#substitute-environment-variables-in-compose-files

and as stated by the documentation, this is my docker-compose.yml:

services:
  web:
   image: "${IMAGE}"

This is my .env.dev file

IMAGE=node:12

And this is the command that I'm running:

docker-compose --env-file ./.env.dev up 

But I'm getting this error:

WARNING: The IMAGE variable is not set. Defaulting to a blank string.
Traceback (most recent call last):
  File "bin/docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 126, in perform_command
  File "compose/cli/main.py", line 1070, in up
  File "compose/cli/main.py", line 1066, in up
  File "compose/project.py", line 615, in up
  File "compose/service.py", line 350, in ensure_image_exists
  File "compose/service.py", line 376, in image
  File "docker/utils/decorators.py", line 17, in wrapped
docker.errors.NullResource: Resource ID was not provided
[50006] Failed to execute script docker-compose
    

Am I doing something wrong?

I've docker-compose 1.27.4

like image 258
Joseph Avatar asked Oct 23 '20 11:10

Joseph


1 Answers

I found in Ubuntu docker-compose I have to go to the directory directly where all files (docker-compose.yml ... and some.env) are located. Afterwards it did work.

Solution was only to cd into the directory:

cd my-folder-with-compose
docker-compose --env-file all.env ...
like image 100
software-undercover Avatar answered Oct 19 '22 00:10

software-undercover