Build containers inside one network instead of using --link
I recently run into an issue when running build using gitlab runner with docker images. I want to test my web app (one container) with selenium (second container). The problem is that the selenium container is a service and it does not know the IP of the main (web) container.
The solution is very simple - create a network
docker network create CI_BUILD_ID
And then run a simple command for each container:
docker network connect CI_BUILD_ID CONTAINER_ID
It can be also achieved by adding a network and then adding
--net=NETWORK_ID to docker run commands.
After all build containers are in the same network - they can see each other.