Unable to set environment variables from .env file

142 views
Skip to first unread message

sorcer...@gmail.com

unread,
Nov 9, 2020, 3:19:32 PM11/9/20
to Vagrant
My OS is Win10, with HyperV disabled. Both Vagrant & Virtual Box are the latest version. Trying to run a Github project. Ran into problems of setting up the environment variables.

In my Vagrantfile on the host OS, to run the docker-compose.yml, I have these statements:

  config.vm.provision :docker, run: "always"
  config.vm.provision :docker_compose,
  yml: "/vagrant/docker-compose.yml",
  rebuild: true,
  run: "always"

I have the vagrantfile, docker-compose.yml and .env files for this project are located in the same folder in my Windows host.
When I ran vagrant up, I got warnings (they were more than warnings, actually all the containers started and stopped almost instantaneously after I ran vagrant up. When I restarted the containers inside the guest OS, these containers stopped within a few seconds.)

The warnings are something like:

WARNING: The POSTGRES_VERSION variable is not set. Defaulting to a blank string.


Note: The problems that I am experiencing is almost identical to this old posting by someone else:
https://sourceforge.net/p/sf-compose/tickets/6581/

I believe failing to set the environment variables is the main reason why the containers fail to run.

I vagrant ssh into the directory inside the virtual OS (Ubuntu) for this project. I can see the vagrantfile, docker-compose.yml, .env are all in the same directory in the guest OS. I nano the contents of these files, they are identical to the same files in my host folder.

I googled, the general conclusion is:
For this to happen (aka unable to set the environment variables), the .env and docker-compose.yml files are not in the same directory where the yml is being run. But in my case, they are.

Can someone please advise me what I should do to set/register the environment variables in the containers?

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages