How to connect to the database if Lemmy is in a docker container?
I've installed Lemmy via ansible, but I figured out that there are problems with emails and after I've created a user, no verification email came, no login is possible and now I have a ghost account I want to delete.
Because I couldn't find an UI element to purge users in the admin panel, I want to do it over postgresql, but I have no idea how to connect to the Lemmy database over a docker container, only thing I've found is to backup/restore the whole database:
You might be able to just run docker-compose exec postgres psql to drop into a shell (you may still need to define the user with -U lemmy)
If you're trying to connect with ane external tool though, you'll need to expose the ports temporarily, which I'm not sure if you can do without restarting the container (after adding the exposed ports to the docket compose file, like 127.0.0.1:5432:5432)
Oh yeah, try specifying the hostname as localhost (I think it's -h, but --help will confirm it). Psql tries by default to connect to that socket, but in docker it does use it.
Basically, you'll need to specify the hostname and user (and if port, which should just be default, then -p 5432)
Keeping in mind that you'll need to have the right user and database name, assuming (based on your original comment) lemmy being the username and the db name might also be lemmy
Edit: this should btw just get you into the db, I have no idea of its a good idea or not to delete a user directly from the db, it might cause issues, but I don't have experience with it, but just generally use postgres in docker with other projects