How to customize the configuration file of the official PostgreSQL Docker image?

后端 未结 11 2073
时光取名叫无心
时光取名叫无心 2020-11-29 16:11

I\'m using the official Postgres Docker image trying to customize its configuration. For this purpose, I use the command sed to change max_connections

11条回答
  •  再見小時候
    2020-11-29 16:44

    I looked through all answers and there is another option left. You can change your CMD value in docker file (it is not the best one, but still possible way to achieve your goal).

    Basically we need to

    • Copy config file in docker container
    • Override postgres start options

    Docker file example:

    FROM postgres:9.6
    USER postgres
    
    # Copy postgres config file into container
    COPY postgresql.conf /etc/postgresql
    
    # Override default postgres config file
    CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
    

    Though I think using command: postgres -c config_file=/etc/postgresql/postgresql.confin your docker-compose.yml file proposed by Matthias Braun is the best option.

提交回复
热议问题