postgres icon indicating copy to clipboard operation
postgres copied to clipboard

Include database configuration examples for compose and swarm deployments

Open zachsa opened this issue 2 years ago • 5 comments

In the "Database Configuration" section on the image docs (https://hub.docker.com/_/postgres), it's easy to see how to override database configuration for docker run commands. I'm currently trying to do this via docker stack deploy..., and am struggling to figure this out.

It would be very helpful if the... via docker stack deploy or docker-compose section included an example of specifying a database parameter such as random_page_cost

zachsa avatar Nov 04 '22 08:11 zachsa

This seems to work - if there is a better way, I'd like to know!

...

volumes:
  pgdata:
    driver: local

services:
  postgis:
    image: $POSTGIS_IMAGE
    command: >-
      postgres
        -c random_page_cost=2
        -c seq_page_cost=1
        -c shared_buffers=512MB
        -c work_mem=32MB
        -c maintenance_work_mem=128MB
        -c wal_buffers=4MB
        -c wal_level=minimal
        -c max_wal_senders=0
        -c fsync=on

...

zachsa avatar Nov 04 '22 09:11 zachsa

That's definitely a very solid solution. 👍

tianon avatar Nov 04 '22 22:11 tianon

Thank you @tianon. It seems to work, though unless I'm imagining things these only get applied on the first container start? (i.e. if I redeploy the Docker stack with different values those don't seem to reflect). Is that correct?

zachsa avatar Nov 15 '22 04:11 zachsa

I'm pretty sure CLI flags like that will apply retroactively (unlike initdb arguments / initdb environment variables).

tianon avatar Nov 15 '22 22:11 tianon

Okay, thank you. I must have confused myself elsewhere

zachsa avatar Nov 16 '22 06:11 zachsa