2

I created a Gitlab CI CD pipline with the gitlab runner and gitlab itself. right now everything runs besides one simple script. It does not copy any files to the volume. I'm using docker-compose 2.7 I also have to say, that I'm not 100% sure about the volumes.

Here is an abstract of my .gitlab-ci.yml

stages:
  - build_single
  - test_single
  - clean_single
  - build_lb
  - test_lb
  - clean_lb
Build_single:
  stage: build_single
  script:
    - docker --version
    - docker-compose --version
    - docker-compose  -f ./NodeApp/docker-compose.yml up --scale slave=1 -d
    - docker-compose  -f ./traefik/docker-compose_single.yml up -d
    - docker-compose  -f ./DockerJMeter/docker-compose.yml up --scale slave=10 -d

When I'm using ls, all the files are in the correct folder.

Docker-compose:

version: '3.7'
services:
  reverse-proxy:
    # The official v2.0 Traefik docker image
    image: traefik:v2.0
    # Enables the web UI and tells Traefik to listen to docker
    command: --api.insecure=true --providers.docker
    ports:
    # The HTTP port
    - "7000:80"
    # The Web UI (enabled by --api.insecure=true)
    - "7080:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik/config_lb:/etc/traefik
    networks:
      - default
networks:
  default:
    driver: bridge
    name: traefik

For JMeter I'm using the copy statement to get the configuration files after it startet. but for traefik I need the files on the booting process for traefik.

I thought ./traefik/config_lb:/etc/traefik with a '.' in front of traefik creates a path in respect to the docker-compose file. Is this wrong? I also have to say, that gitlab and the runner are both dockerized on the host system. So the instanz of docker is running on the host system, and gitlab-runner also using the docker.sock.

Best Regards!

Kira
  • 147
  • 1
  • 13

1 Answers1

1

When you use the gitlab-runner in a docker container, it starts another container, the gitlab-executor based on an image that you specify in .gitlab-ci.yml. The gitlab-runner uses the docker sock of the docker host (see /var/run/docker.sock:/var/run/docker.sock in /etc/gitlab-runner/config.toml) to start the executor.

When you then start another container using docker-compose, again the docker sock is used. Any source paths that you specify in docker-compose.yml have to point to paths on the docker host, otherwise the destination in the created service will be empty (given the source path does not exist).

So what you need to do is find the path to traefik/config_lb on the docker host and provide that as the source.

clemens
  • 6,653
  • 2
  • 19
  • 31
  • ah thank you very much. So i have to mount it first to the gitlab-runner? – Kira May 19 '20 at 20:13
  • I think the best way is to create a volume in docker-compose and use that in both traefik and reverse-proxy services. – clemens May 20 '20 at 06:49
  • ok perfect! After that i just have to mount the volume in the other services? Volumes are still a litle bit complicated to me. – Kira May 20 '20 at 11:05
  • 1
    You can have a look at that: https://stackoverflow.com/questions/44284484/docker-compose-share-named-volume-between-multiple-containers – clemens May 20 '20 at 11:14