DrugojAndrew
DrugojAndrew

Reputation: 47

docker-compose Couldn't find env file: path\variables.env

This is my first time using environment variables in docker-compose.
When I run the docker-compose up command I get the error:
docker-compose Couldn't find env file: ${path}\variables.env
Hereinafter "path" is the path to the project in Windows.
Here is my docker-compose.yml:

version: '3.1'
services:
  geo:
    build:
      context: .
    image:geo_image
    container_name: geo
    ports:
     - "3003:3003"
    volumes:
      - ${path}:/var/geo/data
      - /app/node_modules
      - ${path}:/app
    env_file: variables.env
networks:
  default:
    external:
      name: geonw

The variables.env file is located at the root of the project.
Without variables.env everything works fine.
Tell me, please, what is the error?
I tried giving the full path to the file, but that didn't work either.
I also carefully checked the correct name of the file variables.env, there is no error there.

Upvotes: 1

Views: 2524

Answers (2)

DrugojAndrew
DrugojAndrew

Reputation: 47

I'm sorry, but it was just my stupid mistake and inattention. I created a variables.env file at a level higher than the directory with the docker-compose.yml file.
2 hours wasted...
Answer: The variables.env and docker-compose.yml files must be in the same directory.

Upvotes: 1

furydrive
furydrive

Reputation: 510

Try this should work.. also try with \ slash .\variables.env

version: '3.1'
services:
  geo:
    build:
      context: .
    image:geo_image
    container_name: geo
    ports:
     - "3003:3003"
    volumes:
      - ${path}:/var/geo/data
      - /app/node_modules
      - ${path}:/app
    env_file:
     - ./variables.env
networks:
  default:
    external:
      name: geonw

Upvotes: 0

Related Questions