this post was submitted on 19 Dec 2023
2 points (100.0% liked)
Lemmy Administration
698 readers
1 users here now
Anything about running your own Lemmy instance. Including how to install it, maintain and customise it.
Be sure to check out the docs: https://join-lemmy.org/docs/en/administration/administration.html
If you have any problems, describe them here and we will try to help you fixing them.
founded 4 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If lemmy is actually running in docker then you should rather use network instead of socket file - while it should work I would be afraid of docker shenanigans when it comes to mounting a socket file as volume into the container (it should work, but ...).
You should be able to access postgres over network on the host thru extra_hosts settings:
https://stackoverflow.com/a/43541732
postgres://host.docker.internal:5432
My investigations so far have led me to the conclusion that the Ansible install creates multiple docker containers, including one for Lemmy and one for Postgresql. I need now to figure out how inter-container communications work but the host itself is not used.
Ah right, I assumed you were trying to connect the
lemmy
container to postgres running outside of docker.One important thing to remember with all docker compose files - the service name (the first keys in the
services:
configuration) is also the hostname of that container so to ping lemmy (from some other container in that docker compose) you would doping lemmy
, same for postgresping postgres
- but if the postgres service was nameddb0
then it would beping db0
.You also do not have to expose ports - all containers in that compose share one network (exposing is for outside access).
All together your postgres config for lemmy should like this:
Amazingly helpful, thanks!
Ok, the good news is that it works. The bad news is that I don't understand what changed. 🤨
I don't get what you mean here. Communication over (linux) socket file and TCP/IP is very different.
After reading your comment, I went back to investigate my install. I can't remember having changed anything relevant but Lemmy started to function properly, connecting as it should the database. It's been stable since, even after reboots.
As you suggested, I am using "postgres" as the host, as the service is described in the docker-compose.yml file. The communication is then via TCP/IP and not socket.