[英]could not translate host name "postgres" to address: Name or service not known
[英]Could not translate host name "postgres" to address on github actions
我正在配置我的第一个 Github 操作工作流。 它需要 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
但是 Github 操作无法使用postgres
主机。 有以下步骤:
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
而失败:
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 操作工作流程页面可在此处获得: https://github.com/buxx/rolling/actions/runs/3092460076/jobs/5003751698 。 整个配置文件在这里: https://github.com/buxx/rolling/blob/3e4d200e5e111d3731d7fc8d18e5795a0b82ca9a/.github/workflows/pr-tests.yml
如何配置 Github 操作工作流才能使用 postgresql 服务?
没有关于在容器中执行步骤的特殊指示,步骤正在运行器上运行。 因此,要使用的 postgres 主机是localhost
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.