简体   繁体   English

无法将主机名“postgres”转换为 github 操作上的地址

[英]Could not translate host name "postgres" to address on github actions

I'm configuring my first Github actions workflow.我正在配置我的第一个 Github 操作工作流。 It require postgres, so I added a service like this:它需要 postgres,所以我添加了这样的服务:

    services:
      postgres:
        image: postgres:latest
        env:
          POSTGRES_DB: postgres_db
          POSTGRES_PASSWORD: postgres_password
          POSTGRES_PORT: 5432
          POSTGRES_USER: postgres_user
        ports:
          - 5432:5432
        # set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

But Github actions are unable to use the postgres host.但是 Github 操作无法使用postgres主机。 There is the steps:有以下步骤:

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v3
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install PostgreSQL client   
      run: |
        sudo apt-get update
        sudo apt-get install --yes postgresql-client

    - name: Test database connection
      run: psql -h postgres -d postgres_db -U postgres_user -c 'SELECT 1;'
      env:
        PGPASSWORD: postgres_password

And the failure:而失败:

Run psql -h postgres -d postgres_db -U postgres_user -c 'SELECT 1;'
psql: error: could not translate host name "postgres" to address: Temporary failure in name resolution

Github action workflow page is available here: https://github.com/buxx/rolling/actions/runs/3092460076/jobs/5003751698 . Github 操作工作流程页面可在此处获得: https://github.com/buxx/rolling/actions/runs/3092460076/jobs/5003751698 And entire config file here: https://github.com/buxx/rolling/blob/3e4d200e5e111d3731d7fc8d18e5795a0b82ca9a/.github/workflows/pr-tests.yml整个配置文件在这里: https://github.com/buxx/rolling/blob/3e4d200e5e111d3731d7fc8d18e5795a0b82ca9a/.github/workflows/pr-tests.yml

How to configure Github action workflow to be able to use postgresql service?如何配置 Github 操作工作流才能使用 postgresql 服务?

Without special indication about executing step into container, step is running on the runner.没有关于在容器中执行步骤的特殊指示,步骤正在运行器上运行。 So, postgres host to use is localhost .因此,要使用的 postgres 主机是localhost

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将主机名“postgres”转换为地址:名称或服务未知 - could not translate host name "postgres" to address: Name or service not known 无法将主机名“postgres”转换为地址:名称或服务未知 - DOCKER - Could not translate host name "postgres" to address: Name or service not known - DOCKER Rails 无法将主机名“postgres”转换为地址:名称或服务未知 (PG::ConnectionBad) - Rails could not translate host name “postgres” to address: Name or service not known (PG::ConnectionBad) Heroku上偶尔出现Postgres错误:无法将主机名“<pg URL>”转换为地址:名称或服务未知(PG ::错误) - Occasional Postgres error on Heroku: could not translate host name “<pg URL>” to address: Name or service not known (PG::Error) 无法使用 Postgres、Docker Compose 和 Psycopg2 将主机名“db”转换为地址 - Could not translate host name "db" to address using Postgres, Docker Compose and Psycopg2 无法将主机名转换为“db”到地址:未知主机 - could not translate host name to “db” to address: Unknown host Docker:当使用容器名称从一个容器连接到另一个容器时,如何修复“无法将主机名”postgres“转换为地址”? - Docker: How to fix “could not translate host name ”postgres“ to address” when connecting from one container to another using container name? Docker 图像未运行,数据库错误:django.db.utils.OperationalError 无法将主机名“postgres”转换为地址:名称或服务未知 - Docker image not running, db error: django.db.utils.OperationalError could not translate host name "postgres" to address: Name or service not known Heroku + Postgres:psycopg2.OperationalError:无法翻译主机名“无” - Heroku + Postgres: psycopg2.OperationalError: could not translate host name “None” 无法将主机名“localhost”转换为地址:未知服务器错误 - Could not translate host name “localhost” to address: Unknown server error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM