question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docker-compose config/environment variables not present.

See original GitHub issue

Description

Not able to fire up local prefect server backend / prefect server start environment variables are not loaded when server.py runs docker-compose up

WARNING: The POSTGRES_DB variable is not set. Defaulting to a blank string. WARNING: The POSTGRES_PASSWORD variable is not set. Defaulting to a blank string. WARNING: The POSTGRES_USER variable is not set. Defaulting to a blank string.

Reproduction

No exports in .profile or .bash_rc clean install on linux Ubuntu 18 pip install prefect prefect backend server (copied and adjusted backend.toml with git config.toml) prefect server start, not able to start postgres , warning

env vars from config are present in server.py however subprocess.Popen(… , env=env) not working fires: docker-compose up

creating a .env file where tmp/docker-compose.yml is placed worked, postgres starts however running into new issues graphql not able to connect.

Environment

Python 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0] on linux

Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic

docker-compose version 1.27.4, build 4052419 docker-py version: 4.3.1 CPython version: 3.7.7

Client: Docker Engine - Community Version: 19.03.13 API version: 1.40

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
Jesperrekuhcommented, Oct 28, 2020

Thanks for sharing this, seems like problems are resolved… all docker stuff was up to date / newest.

What I’ve missed: – pip3 install docker-compose

Could reproduce my errors by uninstalling pip3 uninstall docker-compose And all issues returned.

– pip3 install docker-compose I think I missed it in the documenation, however it isnt mentioned here https://docs.prefect.io/core/getting_started/installation.html ?

Again thank you

0reactions
madkinszcommented, Oct 30, 2020

For me to make it work (after installing docker-compose via pip3) I added to docker-compose.yml for GraphQL and Postgres services env_file: .env

.env:

PREFECT_SERVER_DB_CMD=echo ""
POSTGRES_DB=prefect_server
POSTGRES_PASSWORD=prefect
POSTGRES_USER=prefect
PGUSER=prefect
PGPASSWORD=prefect
PGDATABASE=prefect_server
DB_CONNECTION_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}

With this setup it worked and from RHEL and from docker container.

I’m glad you got it working! Since I cannot replicate a situation where a .env file is required and we’ve solved the original issue here I’m going to close this for now. Thanks for your help everyone!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables in Compose | Docker Documentation
When you run docker-compose up with this configuration, Compose looks for the POSTGRES_VERSION environment variable in the shell and substitutes its value in....
Read more >
docker-compose not setting environment variables
docker -compose only sets the environment variables specified in the environment directive in the docker-compose.yaml file during the run phase ...
Read more >
docker-compose does not set environment variables #7423
And I found that environment variables are working only from .env file placed in the folder where the docker-compose command is executed ( ......
Read more >
Taking Advantage of the docker-compose Environment ...
Learn in this article the different ways of declaring docker-compose environment variables. Discover the great flexibility Docker allows in ...
Read more >
How to Use Docker Environment Variables in Docker Compose
You should keep your Docker Compose environment variables inside the actual Compose file and out of the command line. Here's why.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found