Gitlab CI: Add Service DNS Names also to Services
Problem to solve
In my gitlab-ci pipeline I was trying to run a selenium-hub with a chrome node to test my frontend. Problem is, that the node cannot reach the hub, because it does not get its hostname injected to /etc/hosts.
Intended users
I can think of many more services, that have such a dependency of contacting each other to run in the ci, for example a service that needs itself a redis database.
Proposal
Maybe the problem is, that the IPs of all the services are not known, before they are run, but the hostnames could be injected with a simple:
docker exec <service-container-name> sh -c "echo <ip-of-other-service> <hostname-of-other-service> >> /etc/hosts"
After the containers are started.
EDIT: Another possibility is to use a network and predefine all the ip addresses:
https://stackoverflow.com/questions/27937185/assign-static-ip-to-docker-container
Permissions and Security
Nothing I could think of.
Documentation
A selenium hub example with a chrome and firefox node could be added to the examples for services.
Testing
This is for sure a non breaking feature that would not influence any currently working ci files.
What does success look like, and how can we measure that?
Services being able to talk to each other through simple hostname/aliases.