nsidnev/fastapi-realworld-example-app

Set proper host in DB_CONNECTION in .env.example

funnydman opened this issue · 3 comments

Now:
DB_CONNECTION=postgres://postgres:postgres@localhost/postgres

Expected:
DB_CONNECTION=postgres://postgres:postgres@db/postgres

The hostname for connection is the same as a service name, so this information is considered permanent.

Not sure about that. The reason for placing localhost here was to simplify cloning and running to test any changes. Yes, this value is not suitable for working with compose by default, but it’s more convenient when you want to change something and check if everything works as expected.

Personally, I do not use compose for deployment, so this will not help me, and when I want to check that the application works fine in the container, I just change the host.

But can, as an alternative, set this value in docker-compose.yml in the app service?

Yep, we could set this in docker-compose.yml

@nsidnev Hey, in the end, I found it's better to leave it as it is at least for now. Feel free to close this issue.