AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1126698
Accepted
tuk
tuk
Asked: 2023-03-21 03:29:46 +0800 CST2023-03-21 03:29:46 +0800 CST 2023-03-21 03:29:46 +0800 CST

如何通过撰写文件将服务器配置传递给 postgres docker?

  • 772

我正在使用 Postgres docker 14.4。我想将服务器配置(比方说idle_session_timeout)传递给 postgres docker。该文档给出了一个使用 docker run 的示例

docker run -d --name test-db -e POSTGRES_PASSWORD=postgres postgres -c idle_session_timeout=900000

如何在 docker-compose 中传递此选项?我的 docker-compose 文件现在如下所示 -

version: '3'
services:
  pgadmin:
    container_name: pgadmin
    image: dpage/pgadmin4
    ports:
      - "6555:80"       # pg admin
      - "6432:6432"     # postgres-db
    environment:
      PGADMIN_DEFAULT_EMAIL: [email protected]
      PGADMIN_DEFAULT_PASSWORD: admin

  postgres-db:
    container_name: test-db
    image: postgres:14.4
    network_mode: "service:pgadmin"
    command: -p 6432
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      PGUSER: postgres
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -p 6432"]
      interval: 5s
      timeout: 5s
      retries: 3
docker
  • 1 1 个回答
  • 22 Views

1 个回答

  • Voted
  1. Best Answer
    tuk
    2023-03-27T00:52:43+08:002023-03-27T00:52:43+08:00

    它可以在command部分中传递。设置为 15 分钟的更新的 docker-compose 文件idle_session_timeout如下所示

    version: '3'
    services:
      # IMPORTANT NOTE: All other services will share the network on pgadmin service (network_mode: "service:pgadmin"), so ports need to be opened here instead of other the services.
      # It is added for debugging purpose & may be removed in future when the tests using docker container looks stable
      pgadmin:
        container_name: pgadmin
        image: dpage/pgadmin4
        ports:
          - "6555:80"       # pg admin
          - "6432:6432"     # postgres-db
        environment:
          PGADMIN_DEFAULT_EMAIL: [email protected]
          PGADMIN_DEFAULT_PASSWORD: admin
    
      postgres-db:
        # Postgres version should be compatible with Aurora:
        # https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Updates.20180305.html
        container_name: test-db
        image: postgres:14.4
        network_mode: "service:pgadmin"
        command: -p 6432 -c idle_session_timeout=900000
        environment:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          PGUSER: postgres
        healthcheck:
          test: ["CMD-SHELL", "pg_isready -p 6432"]
          interval: 5s
          timeout: 5s
          retries: 3
    
    • 0

相关问题

  • 当你让一个进程监听 0.0.0.0 而不是 127.0.0.1 时,为什么 docker 工作仍然很困惑

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve