Nowadays, everybody is trying to run everything in container and I don’t blame them, I do the same thing, because running applications, databases or other tools in Docker container is super nice and we all know why (isolation, easy setup, security…). However, sometimes debugging, accessing, or in general interacting with containers can be pretty annoying. This includes accessing, modifying or querying databases. So, as I used PostgreSQL extensively and have been running it inside containers for a while now, I — over time — made a list of few commands that can help immensely when doing simple and also not so simple operation with a database server.
Source: Tricks for Postgres and Docker that will make your life easier, an article by Martin Heinz.