Runner Container Hooks cannot resolve service container by name
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Describe the bug
--network-alias postgres is missing for the service container docker create command, while it is set for the internal container implementation and job container are unable to resolve service container by name
To Reproduce
Steps to reproduce the behavior:
-
Enable runner container hooks (docker)
-
on: push jobs: _: runs-on: container-runner container: node:latest services: postgres: # Docker Hub image image: postgres # Provide the password for postgres env: POSTGRES_PASSWORD: postgres # Set health checks to wait until postgres has started options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 env: PGPASSWORD: postgres steps: - run: ${{ tojson(job) }} shell: cat {0} - run: | curl -vv postgres || : - run: | apt-get update apt-get install --yes --no-install-recommends postgresql-client - name: Test-${{ inputs.Test }}-end run: | psql -h postgres -U postgres -c 'CREATE DATABASE Test' -
See name resolution error for postgres
Expected behavior
postgres is a resolveable hostname for the service container postgres and --network-alias postgres is used for the service container.
Runner Version and Platform
Version of your runner? 2.304.0
OS of the machine running the runner? Linux
I checked the source code, the problem has not been resolved between 2.304.0 and latest.
What's not working?
[command]/usr/bin/docker create --label=636f6e7461696e65722d72756e6e6572 --network=github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b --name 06677c6373a94b558a6bbf2f18a1cd1e__7515d3 --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -e POSTGRES_PASSWORD postgres
...
psql: error: could not translate host name "postgres" to address: Temporary failure in name resolution
After looking at the source code I noticed that:
has no contextName field (ContainerInfo.ContainerNetworkAlias), which is expected for service container.
Therefore the following condition is never satisfied:
Job Log Output
urrent runner version: '2.304.0'
Runner name: 'container-runner'
Runner group name: 'Default'
Machine name: '86df98fff5bf'
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Complete job name: _
##[group]Run '/runner/index.js'
shell: /runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker ps --all --quiet --no-trunc --filter label=636f6e7461696e65722d72756e6e6572
[command]/usr/bin/docker network prune --force --filter label=636f6e7461696e65722d72756e6e6572
[command]/usr/bin/docker network create --label 636f6e7461696e65722d72756e6e6572 github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b
330aae9ac92c9c4afc2719d36cf2fba5a5c0ead2439ddbf36cf1f6ff256dc8ff
[command]/usr/bin/docker pull node:latest
latest: Pulling from library/node
Digest: sha256:8d9887b3b05d2e65598a18616c37cfc271346d12248dfcbeadd7b7bf4da1e827
Status: Image is up to date for node:latest
docker.io/library/node:latest
[command]/usr/bin/docker create --label=636f6e7461696e65722d72756e6e6572 --network=github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b --name 0df272070e6f4f8692209723d931f807__d28ac4 -e HOME -e NODE_EXTRA_CA_CERTS -v=/var/run/docker.sock:/var/run/docker.sock -v=/runner/_work:/__w -v=/runner/externals:/__e -v=/runner/_work/_temp:/__w/_temp -v=/runner/_work/_actions:/__w/_actions -v=/runner/_work/_tool:/__w/_tool -v=/runner/_work/_temp/_github_home:/github/home -v=/runner/_work/_temp/_github_workflow:/github/workflow --entrypoint tail node:latest -f /dev/null
de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
[command]/usr/bin/docker start de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
[command]/usr/bin/docker cp /etc/ssl/certs/ca-certificates.crt de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd:/__w/certs.pem
[command]/usr/bin/docker cp /usr/local/share/ca-certificates/. de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd:/usr/local/share/ca-certificates/
[command]/usr/bin/docker exec de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd update-ca-certificates
Updating certificates in /etc/ssl/certs...
rehash: warning: skipping ca-certificates.crt,it does not contain exactly one certificate or CRL
2 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
[command]/usr/bin/docker pull postgres
Using default tag: latest
latest: Pulling from library/postgres
Digest: sha256:a5e89e5f2679863bedef929c4a7ec5d1a2cb3c045f13b47680d86f8701144ed7
Status: Image is up to date for postgres:latest
docker.io/library/postgres:latest
[command]/usr/bin/docker create --label=636f6e7461696e65722d72756e6e6572 --network=github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b --name 06677c6373a94b558a6bbf2f18a1cd1e__7515d3 --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -e POSTGRES_PASSWORD postgres
06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
[command]/usr/bin/docker start 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
[command]/usr/bin/docker exec de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd sh -c [ $(cat /etc/*release* | grep -i -e '^ID=*alpine*' -c) != 0 ] || exit 1
[command]/usr/bin/docker port de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
[command]/usr/bin/docker port 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
[command]/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
[command]/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
""
Healthcheck is not set for container node:latest, considered as healthy
"starting"
Container 'postgres' is 'starting', retry in 2 seconds
[command]/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
"starting"
Container 'postgres' is 'starting', retry in 4 seconds
[command]/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
"starting"
Container 'postgres' is 'starting', retry in 8 seconds
[command]/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
"healthy"
All services are healthy
##[group]Run {
{
"status": "success",
"container": {
"id": "de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd",
"network": "github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b"
},
"services": {
"postgres": {
"id": "06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633",
"ports": {},
"network": "github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b"
}
}
}
shell: cat {0}
env:
PGPASSWORD: postgres
##[endgroup]
##[group]Run '/runner/index.js'
shell: /runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker exec -i --workdir=/__w/container-runner/container-runner -e PGPASSWORD -e GITHUB_JOB -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_REPOSITORY -e GITHUB_SHA -e GITHUB_REF -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REPOSITORY_OWNER -e GITHUB_REPOSITORY_OWNER_ID -e GITHUB_REPOSITORY_ID -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_REF_PROTECTED -e GITHUB_RETENTION_DAYS -e GITHUB_BASE_REF -e GITHUB_HEAD_REF -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e GITHUB_OUTPUT -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd cat /__w/_temp/10773431-66ac-4820-b72e-a4e635304696
{
"status": "success",
"container": {
"id": "de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd",
"network": "github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b"
},
"services": {
"postgres": {
"id": "06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633",
"ports": {},
"network": "github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b"
}
}
}
##[group]Run curl -vv postgres || :
curl -vv postgres || :
shell: sh -e {0}
env:
PGPASSWORD: postgres
##[endgroup]
##[group]Run '/runner/index.js'
shell: /runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker exec -i --workdir=/__w/container-runner/container-runner -e PGPASSWORD -e GITHUB_JOB -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_REPOSITORY -e GITHUB_SHA -e GITHUB_REF -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REPOSITORY_OWNER -e GITHUB_REPOSITORY_OWNER_ID -e GITHUB_REPOSITORY_ID -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_REF_PROTECTED -e GITHUB_RETENTION_DAYS -e GITHUB_BASE_REF -e GITHUB_HEAD_REF -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e GITHUB_OUTPUT -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd sh -e /__w/_temp/58a30b55-d8a1-4f75-9de6-09c1fe3dc03e.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:06 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:07 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:08 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0* Could not resolve host: postgres
* Closing connection 0
curl: (6) Could not resolve host: postgres
##[group]Run apt-get update
apt-get update
apt-get install --yes --no-install-recommends postgresql-client
shell: sh -e {0}
env:
PGPASSWORD: postgres
##[endgroup]
##[group]Run '/runner/index.js'
shell: /runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker exec -i --workdir=/__w/container-runner/container-runner -e PGPASSWORD -e GITHUB_JOB -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_REPOSITORY -e GITHUB_SHA -e GITHUB_REF -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REPOSITORY_OWNER -e GITHUB_REPOSITORY_OWNER_ID -e GITHUB_REPOSITORY_ID -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_REF_PROTECTED -e GITHUB_RETENTION_DAYS -e GITHUB_BASE_REF -e GITHUB_HEAD_REF -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e GITHUB_OUTPUT -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd sh -e /__w/_temp/2bceceb9-91a0-400f-aff0-ecd1e3e98c2f.sh
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [47.9 kB]
Get:4 http://deb.debian.org/debian bookworm/main arm64 Packages [8803 kB]
Get:5 http://deb.debian.org/debian bookworm-updates/main arm64 Packages [4736 B]
Get:6 http://deb.debian.org/debian-security bookworm-security/main arm64 Packages [57.6 kB]
Fetched 9117 kB in 11s (852 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
postgresql-client-15 postgresql-client-common
Suggested packages:
postgresql-15 postgresql-doc-15
The following NEW packages will be installed:
postgresql-client postgresql-client-15 postgresql-client-common
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1686 kB of archives.
After this operation, 9144 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main arm64 postgresql-client-common all 248 [35.1 kB]
Get:2 http://deb.debian.org/debian bookworm/main arm64 postgresql-client-15 arm64 15.3-0+deb12u1 [1641 kB]
Get:3 http://deb.debian.org/debian bookworm/main arm64 postgresql-client all 15+248 [10.1 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 1686 kB in 1s (1330 kB/s)
Selecting previously unselected package postgresql-client-common.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 23282 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_248_all.deb ...
Unpacking postgresql-client-common (248) ...
Selecting previously unselected package postgresql-client-15.
Preparing to unpack .../postgresql-client-15_15.3-0+deb12u1_arm64.deb ...
Unpacking postgresql-client-15 (15.3-0+deb12u1) ...
Selecting previously unselected package postgresql-client.
Preparing to unpack .../postgresql-client_15+248_all.deb ...
Unpacking postgresql-client (15+248) ...
Setting up postgresql-client-common (248) ...
Setting up postgresql-client-15 (15.3-0+deb12u1) ...
update-alternatives: using /usr/share/postgresql/15/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-client (15+248) ...
##[group]Run psql -h postgres -U postgres -c 'CREATE DATABASE Test'
psql -h postgres -U postgres -c 'CREATE DATABASE Test'
shell: sh -e {0}
env:
PGPASSWORD: postgres
##[endgroup]
##[group]Run '/runner/index.js'
shell: /runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker exec -i --workdir=/__w/container-runner/container-runner -e PGPASSWORD -e GITHUB_JOB -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_REPOSITORY -e GITHUB_SHA -e GITHUB_REF -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REPOSITORY_OWNER -e GITHUB_REPOSITORY_OWNER_ID -e GITHUB_REPOSITORY_ID -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_REF_PROTECTED -e GITHUB_RETENTION_DAYS -e GITHUB_BASE_REF -e GITHUB_HEAD_REF -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e GITHUB_OUTPUT -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd sh -e /__w/_temp/f30b0995-7b9c-4488-804d-debad9914d44.sh
psql: error: could not translate host name "postgres" to address: Temporary failure in name resolution
##[error]Error: The process '/usr/bin/docker' failed with exit code 2
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.
##[group]Run '/runner/index.js'
shell: /runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker ps --all --quiet --no-trunc --filter label=636f6e7461696e65722d72756e6e6572
06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
[command]/usr/bin/docker rm --force 06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633 de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
06f2e90e0309a0847f891ada13b7f3ca5762f68ae254abfb77833b5ad74ba633
de750b575687fbb26ebe3cbb9eaca196c8adf8fd1a84c70f24a37798aa7408fd
[command]/usr/bin/docker network prune --force --filter label=636f6e7461696e65722d72756e6e6572
Deleted Networks:
github_network_bd31f318-c733-4dd8-9f20-b98a79280c5b
Cleaning up orphan processes
Runner and Worker's Diagnostic Logs
Not applicable.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with HookInput.cs at the linked lines and trace how service-container context reaches packages/docker/src/dockerCommands/container.ts, especially the contextName and ContainerNetworkAlias fields. Reproduce the workflow with a postgres service and verify that the job container can resolve postgres by name and that the generated docker create command includes the expected alias.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, docker, typescript
- Domain
- devops, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100