Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase max_connection in the official PostgreSQL Docker image

Problem

I have too many connection open using the default docker postgresql configuration

  • https://hub.docker.com/_/postgres/

Goal

I want to extend max_connection without using a volume for mounting the configuration (I need this to be available by default for my CI environment).

I have tried to use sed to edit the configuration but this has no effect.

What is the recommended way of overriding default configuration of postgresql docker official image?

like image 899
Dimitri Kopriwa Avatar asked Nov 12 '17 17:11

Dimitri Kopriwa


People also ask

Where is PostgreSQL conf Docker?

The default postgresql. conf file lives within the PGDATA dir ( /var/lib/postgresql/data ), which makes things more complicated especially when running the Postgres container for the first time, since the docker-entrypoint.sh wrapper invokes the initdb step for PGDATA dir initialization.

What is Max_connections in postgres?

max_connections ( integer ) Determines the maximum number of concurrent connections to the database server. The default is typically 100 connections, but might be less if your kernel settings will not support it (as determined during initdb). This parameter can only be set at server start.


1 Answers

run this docker-compose.yml

version: '2' services:   postgres:     image: postgres:10.3-alpine     command: postgres -c 'max_connections=200'     environment:       POSTGRES_DB: pgdb       POSTGRES_PASSWORD: postgres       POSTGRES_USER: postgres     stdin_open: true     tty: true     ports:     - 5432:5432/tcp 
like image 188
Piero Avatar answered Sep 28 '22 05:09

Piero