我正在使用官方的Postgres Docker图像来尝试自定义其配置.为此,我使用命令sed进行更改max_connections,例如:
sed -i -e"s/^max_connections = 100.*$/max_connections = 1000/" /var/lib/postgresql/data/postgresql.conf
Run Code Online (Sandbox Code Playgroud)
我尝试了两种方法来应用此配置.第一种方法是将命令添加到脚本并在init文件夹"/docker-entrypoint-initdb.d"中复制它.第二种方法是使用"RUN"命令在我的Dockerfile中直接运行它们(这种方法适用于非官方的Postgresql映像,配置文件的路径不同于"/ etc/postgres/...").在这两种情况下,更改都会失败,因为配置文件丢失(我认为它尚未创建).
我该如何更改配置?
编辑1:
这是用于创建图像的Dockerfile:
# Database (http://www.cs3c.ma/)
FROM postgres:9.4
MAINTAINER Sabbane <contact@cs3c.ma>
ENV TERM=xterm
RUN apt-get update
RUN apt-get install -y nano
ADD scripts /scripts
# ADD scripts/setup-my-schema.sh /docker-entrypoint-initdb.d/
# Allow connections from anywhere.
RUN sed -i -e"s/^#listen_addresses =.*$/listen_addresses = '*'/" /var/lib/postgresql/data/postgresql.conf
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf
# Configure logs
RUN sed -i -e"s/^#logging_collector = off.*$/logging_collector = on/" /var/lib/postgresql/data/postgresql.conf …Run Code Online (Sandbox Code Playgroud)