Access running docker container via network from docker executer

I’m running the gitlab-runner in a docker container. I’m using the docker executer and I’m trying to connect an Android Emulator running as docker container. Unfortunately there’s no support for services using devices like /dev/kvm which the Android Emualtor-Container heavily relies on (see this issue and this one). As a worka around I’d like to run the Android Emulator Container on the host and access it via network from the job:

    stage: test
        - apt-get update
        - apt-get install iputils-ping -y
        - ping android-emulator
        - adb connect android-emulator:5555

I can ping the emulator from the gitlab-runner container but the ping within the jobs fails:
ping: android-emulator: Name or service not known

Is this even possible?

Thanks for your help.

The immediate issue is likely that the DNS is not propagating within (but there can be a subsequent issue where the network isn’t setup to access services on the host).

The job runtime cannot resolve android-emulator to any known IP address. You can try manually defining a hosts entry via the extra_hosts docker runner configuration, or try connecting with the IP of the host android-emulator directly if the route permits it.

Thanks for your answer. I looked up the follwing IP adresses:

  • Android Emulator: /16
  • Gitlab Runner:
  • Job Container:

So the job container is in a seperate docker network. There’s no routing between docker networks by design (source) . So I can’t ping even using the IP address to exclude DNS problems. But because the port 5555 of the Emulator container is published to the host, I can reach it via host’s IP address with e.g. telnet <IP_HOST> 5555. Firewall was first blocking the connection. On Ubuntu I added the follwing rule to ufw:
sudo ufw allow from to any port 5555

It’s working now fine, thank you!