kompose: Unable to read env_file that works with docker-compose up

I have this structure: .env is in the root, docker-compose is two levels deep.

/root/.env /root/src/net/docker-compose.yml

In docker-compose.yml, I reference the .env file like this:

  azsdkdemoapi:
    image: azsdkdemoapi
    env_file: ../../.env
    build:
      context: .
      dockerfile: Api/Dockerfile

This works when I run docker-compose up.

If I run kompose convert, I get the following: ←[31mFATA←[0m Unable to retrieve env file: Unable to read env_file: open ../.env: The system cannot find the file specified.

I’ve tried this in Git Bash, WSL, and Windows CMD.

It only works if the .env file is at the same level as the docker-compose file.

azsdke2e

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

same issue on version 1.30.0 (9d8dcb518) on ubuntu 22.04. Working directory path is written twice and because of that kompose is unable to retrieve the .env file

Same issue

FATA Unable to retrieve env file: Unable to read env_file: open /root/git/laradock/root/git/laradock/.env: no such file or directory

I’m having the same issue. kompose version returns 1.30.0 (9d8dcb518).

I built the image using this tutorial

It gives me this error:

Unable to read env_file: open /opt/opt/.env: no such file or directory

Can anyone reopen this issue?

I confirmed that this is resolved in 1.22

Thank you

image

This is the result using v1.22. Would you guys mind to give it another try?