docker-compose --env-file is not working at all
Asked Answered
O

1

13

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

Orion answered 23/10, 2020 at 11:23 Comment(2)
works fine for me! change your docker-compose.yml to have versionRepand
I have version 3.7 on topOrion
U
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 ...
Unscrew answered 24/2, 2021 at 12:29 Comment(1)
this thing is so fragileConsultation

© 2022 - 2025 — McMap. All rights reserved.