We have a project that starts some docker containers in a network as part of integration testing. Then the application (running in the drone env) tries to communicate with them.
Which then fails, since the drone container running the test and those containers are on separate docker networks.
One workaround would be to start those containers from drone itself in drone.yml, but we don’t want to introduce drone as a dependancy. Now users can run those tests locally with no issues (since their host environment just creates a docker network and everything works fine, there is no sibling networking going on)
Is there a way to connect drone env to some specific docker network? The project also has access to docker.sock if that makes any difference.
Thought I’d post an update if someone encounters the same problem.
This is not the prettiest, since drone leaks into the project, but otherwise works:
In your project check if DRONE=true is set in the environment. If so - you’re running in drone container.
Since you have access to docker.sock you can make this container join the required network, just need to find the containerId. Luckily HOSTNAME is set to its’ value, so just run docker network connect [networkId] [containerId] and that’s that.