Skip to content

Docker container talks to service container #26094

Answered by airtower-luna
mfridman asked this question in Actions
Discussion options

You must be logged in to vote

Based on how Docker networking works: You’d just need to connect your container to the same network as the service containers. According to documentation the name of the network is available in the job context as job.container.network, so something like this should work:

steps:
  - name: test docker connection
    run: docker run --rm --network ${{ job.container.network }} postgres:11.8-alpine sh -c "exec psql -h postgres -d postgres -p 5432 -U user -t -c 'SELECT datname FROM pg_database;"

My guess is that they use a custom network because Docker doesn’t provide DNS on the default network.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants