I’ve added ecto to my Elixir app. On host it’s running fine, because ecto can connect to local db. But I don’t understand, what i need to do, if this app running in docker container.
I’m getting this error: 11:42:31.536 [error] Postgrex.Protocol (#PID<0.249.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
And I understand, that docker container with my app doesn’t have postgresql at localhost inside. But i don’t understand, how configure this.
P.S. I’m trying to learn Docker, Elixir, Ecto, Postgresql.
Instead of localhost connect to whatever the hostname of postgres is in your docker setup. What that is depends on your general setup – postgres within docker or postgres on the host running docker – as well as potentially the specific name you gave things.