我正在使用Postgres作为一个服务在我的码头-撰写文件。我希望在执行docker-compose up
时启用日志记录文件。启用日志记录的一种方法是编辑postgres.conf
文件,但在本例中并不有用。另一种方法是做这样的事
docker run --name postgresql -itd --restart always sameersbn/postgresql:10-2 -c logging_collector=on
但是这也没有什么用,因为我不是从图像开始的,而是作为一个坞-撰写服务。您知道我如何在Postgres中启用日志记录来启动对接器吗?
发布于 2019-12-30 09:39:19
docker run --name postgresql -itd --restart always sameersbn/postgresql:10-2 -c logging_collector=on
将-c logging_collector=on
参数添加到ENTRYPOINT ["/sbin/entrypoint.sh"]
以启用日志记录。(Dockerfile)。
command:
:version: "3.7"
services:
database:
image: sameersbn/postgresql:10-2
command: "-c logging_collector=on"
# ......
当Postgresql运行时,它将运行命令:/sbin/entrypoint.sh -c logging_collector=on
。
发布于 2019-12-30 09:15:53
下面是用于在compose中运行命令-c
的docker-compose
version: '3.6'
services:
postgresql:
image: postgres:11.5
container_name: platops_postgres
volumes: ['platops-data:/var/lib/postgresql/data/', 'postgress-logs:/var/log/postgresql/']
command: ["postgres", "-c", "logging_collector=on", "-c", "log_directory=/logs", "-c", "log_filename=postgresql.log", "-c", "log_statement=all"]
environment:
- POSTGRES_USER=postgresql
- POSTGRES_PASSWORD=postgresql
ports: ['5432:5432']
volumes:
platops-data: {}
# uncomment and set the path of the folder to maintain persistancy
# data-postgresql:
# driver: local
# driver_opts:
# o: bind
# type: none
# device: /path/of/db/postgres/data/
postgress-logs: {}
# uncomment and set the path of the folder to maintain persistancy
# data-postgresql:
# driver: local
# driver_opts:
# o: bind
# type: none
# device: /path/of/db/postgres/logs/
有关更多信息,您可以使用容器/后置查询。
https://stackoverflow.com/questions/59527291
复制相似问题