Docker container talks to service container #26094
-
Hi, I have a service container (postgres) running. As outlined in workflows/postgres-service.yml The job and all the steps are running on a Linux Runner (not inside a docker container). But, I’d like to invoke a docker container on the runner to run a command inside a container talking to the service container. E.g.,
This works. But now I’d like to run the exact same command from within a docker container targeting the service postgres container:
This fails, because the 2 containers are on different networks. Is it possible to run the jobs on Linux Runner (not container) while invoking a docker container with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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
My guess is that they use a custom network because Docker doesn’t provide DNS on the default network. |
Beta Was this translation helpful? Give feedback.
-
airtower-luna:
Awesome, Indeed each gets a unique docker network.
thank you @airtower-luna |
Beta Was this translation helpful? Give feedback.
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 asjob.container.network
, so something like this should work:My guess is that they use a custom network because Docker doesn’t provide DNS on the default network.