skip to Main Content

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


  1. Chosen as BEST ANSWER

    I figured a solution that seems to run for now:

    1. Create a network, e.g docker network create gitlab-runner (bridge-mode)
    2. Configure the gitlab-runner to use that network by setting the network_mode to afore created networks name (e.g. "gitlab-runner").
    3. Start the dind-container manually, connected to afore created network, exposing the necessary port(ranges)
    4. Don't create the dind-container as service in the .gitlab-ci.yml

    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.

    Actually the errors are related to this issue: With this method, the checked out project is available in the docker/compose-container. When starting the containers, this is done from the context of the dind-container, in which the files are not present.
    The files could be copied with a "build"-step in a new docker container first or made available through a shared volume.


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search