How to correct set work_mem amd max_wal_size in my postgres image

Viewed 2527

I want to set to my postgres image some configuration, need increas work_mem and max_wal_size, but faced with error

/usr/local/bin/docker-entrypoint.sh: line 315: exec: postgres -c max_wal_size=2GB -c work_mem=2GB: not found

varsions

Docker version 19.03.8, build afacb8b7f0
docker-compose version 1.23.1, build b02f1306

and my docker compose

version: '3'
services:

postgres:
    image: postgres:11-alpine
    shm_size: 5g
    command: postgres -c max_wal_size=2GB -c work_mem=2GB
    ports:
        - '5432:5432'
    container_name: 'postgresql_alpine'
    working_dir: /app
    restart: always
    environment:
        POSTGRES_DB: ${POSTGRES_DB}
        POSTGRES_USER: ${POSTGRES_USER}
        POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
        LC_COLLATE: 'sv_SE.UTF-8'
        LC_CTYPE: 'sv_SE.UTF-8'
    volumes:
        - ./data/postgresql:/var/lib/postgresql/data
    networks:
        - php

and error

ivan@ivan-laptop:~/hosts/docker-symfony$ docker logs d30c27661a48
/usr/local/bin/docker-entrypoint.sh: line 315: exec: postgres -c max_wal_size=2GB -c work_mem=2GB: not found

how to correct set work_mem amd max_wal_size in my postgres image?

RESOLVE First I remove dir data/postgres and create again, then I removed all

docker system prune -a --volumes

images and rebuilded and up again

1 Answers

Default postgres Docker image entrypoint takes parameters directly, you should omit postgres in the command sequence.

version: '3'

services:
  postgres:
    image: postgres:12-alpine
    ...
    command: >
      -c work_mem=256MB
      -c maintenance_work_mem=256MB
      -c max_wal_size=1GB
    ...
Related