0

I came accross a URL syntax in a config file, but I don't get the meaning of some of it:

DATABASE_URL=postgresql://myuser:myuser@db:5432/db_prod

More specifically:

  1. the //myuser:myuser part. This is the url that Flask (a web service in my docker-compose file) uses to connect to the db (postgres). The username for the postgres db is indeed myuser as defined in POSTGRES_USER environment variable, however I don't get why this is repeated here.

  2. The meaning of =postgresql:. That's not the name of my service, nor the name of the image (which is postgres:13.1).

The rest is clear to me:

  • db: name of the service in the docker network
  • db_prod: name of the database to connect to
  • 5432: the port on which the db services listen to on the local docker network

thanks!

logicOnAbstractions
  • 2,178
  • 4
  • 25
  • 37
  • From https://stackoverflow.com/questions/3582552/postgresql-connection-url Syntax : postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...] – sanjay Dec 02 '20 at 16:01
  • `DATABASE_URL=...` probably assigns that URL to an environment variable or similar setting. The URL syntax is explained pretty well in the question @sanjay cites (and follows the generic URL `scheme://user:pass@host:port/path` syntax). – David Maze Dec 02 '20 at 16:03
  • *facepalm* yes that actually makes sense. I was so deep thinking about docker configs that it didn't really occur to me this isn't so much a docker question as a postgres question. THank you. – logicOnAbstractions Dec 02 '20 at 16:56

0 Answers0