11

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

Joseph
  • 1,029
  • 13
  • 26

1 Answers1

4

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 ...
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61