I like to set up a gitlab repository and a gitlab-ci with docker-compose for integration tests.
I finally managed to start some containers with docker-compose.
image: docker/compose:1.29.2
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_HOSTNAME: myhost
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "" #TODO
services:
- name: docker:dind
alias: docker
command: [
"--registry-mirror=https://artifactory.mycorp.net"
]
Now I am faced with the problem, that I need network interaction with some services that run on a windows server with (for the tests irrelevant) UI and stuff – so I can not dockerize them with adequate effort.
The gitlab-runner runs exclusively on the server for this one project only!
My idea is, I need to get the docker:dind-service to be on the host-network, so the docker-containers that are spawned inside that service will be available through their explicitly exposed ports. However I have no clue on how I might achieve that.
Any other way to solve that problem is also welcome!
2
Answers
I figured a solution that seems to run for now:
docker network create gitlab-runner
(bridge-mode)network_mode
to afore created networks name (e.g. "gitlab-runner").So far it seems to work for a minimal example starting up zookeeper, kafka and a kafka-restproxy.
For the full project I still have some errors, but I assume they are unrelated to this issue. If it turns out to be wrong, I'll keep you updated.
You gotta make sure that both services are within the same docker network to achieve what you want. Generally when creating images they are assume different networks but this can be configured by u to allow them share the same network.
Below is an example of what I mean. Do the same for ur containers
docker network create db_network docker run -d --name mysql-spi1 --publish 3306 --network db_network --restart unless-stopped --env MYSQL_ROOT_PASSWORD=ebsbduabdc --volume mysqlspi-datadir:/var/lib/mysql mysql:8 --default-authentication-plugin=mysql_native_password