Answer the question
In order to leave comments, you need to log in
How to set up Postgres in Docker?
Hey!
I have a web application. The PosgreSQL database is used, a separate VPS is allocated for it, there is now an SSD, 1 Intel Xeon E5-2620 core and 2GB of RAM. I deploy Postgres via docker compose like this:
version: '2'
services:
postgres:
image: postgres:10
ports:
- 5432:5432
volumes:
- postgres:/var/lib/postgresql/data
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
command: postgres -c shared_buffers=512MB -c effective_cache_size=1536MB -c work_mem=2621kB -c maintenance_work_mem=128MB
shm_size: '1gb'
volumes:
postgres:
Answer the question
In order to leave comments, you need to log in
Why do you need it? Tell me why? So far, none of the docker adepts I have met have coped with such a simple question "why do you need a base in the docker?", maybe you can handle it.
To use the base you must provide a normal file system, you must provide the host network. Insulation? So you have a system entirely under the base and so on. Migrating to another host? Yes, you only have base binaries in this docker. Exactly the same as in the repositories, the base itself is outside in a normal FS. In principle, you will not drag datadir to another architecture. Several clusters of bases on one machine? And why docker for this? There are some awesome pg_ctlcluster scripts on ubuntu/debian. About the perversions with pg_upgrade updating the database, I will not reprint the answer from ruSO.
In the opinion of postgresql dba, you did not pass any settings at all, and work_mem was completely reduced, it has a default of 4mb. Accordingly, the database will work by default, i.e. from the calculation to start on any calculator, and not to work clearly. Not enough, respectively, everything. More aggressive checkpointer, bgwriter and autovacuum settings first.
See pg_stat_statements for queries
1. Is there a specific use of Postgres in docker?There is. Typically, DBMSs are deployed in clusters on bare metal, and docker and orchestration tools are used for applications.
-v/--volume/volumes
everything related to them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question