4

I have an issue with gitlab runner using docker:dind service.

I'm trying to run a docker-compose file with simple volume on a job, here the job :


test_e2e:
  image: tmaier/docker-compose
  stage: test
  services:
    - docker:dind
  variables:
    GIT_STRATEGY: none
    GIT_CHECKOUT: "false"
    DOCKER_DRIVER: overlay2
  before_script:
    - ls
  script:
    - cp .env.dist .env
    - docker-compose -f docker-compose.yml -f docker-compose-ci.yml up -d

The job start normally but a container in docker-compose-ci.yml doesn't seem to mount the volume as specified in it, here docker-compose-ci.yml

version: '3.3'

services:
  wait_app:
    image: dadarek/wait-for-dependencies
    networks:
      - internal
    depends_on:
      - traefik
      - webapp
    command: webapp:3000
  cypress:
    # the Docker image to use from https://github.com/cypress-io/cypress-docker-images
    image: "cypress/included:6.5.0"
    networks:
      - internal
    depends_on:
      - traefik
      - webapp
      - api
      - mysql
      - redis
    environment:
      # pass base url to test pointing at the web application
      - CYPRESS_baseUrl=http://app.localhost:3000
    working_dir: /cypress
    volumes:
      - ./cypress/:/cypress

Here if I make an "docker exec app_cypress_1 sh -c "ls -al" || 1" of /cypress folder inside the container cypress, I will have nothing even though I do have files in there on the host.

But I tried on a different version of the runner 13.7.0 instead of 13.5.0, and it work as expected.

Where could be the issue ? Is it the gitlab runner are maybe there is another parameter that I can change to make it work ?

Thank you

David Maze
  • 130,717
  • 29
  • 175
  • 215
mhlsf
  • 303
  • 4
  • 14
  • The `dind` service looks for the bind mount inside it's container, not from your checkout. You'd need to share the workspace with the `dind` container. Had the same issue with the github `actions-runner` https://blog.lazybit.ch/github-actions-runners-self-hosted-in-kubernetes/. – masseyb Mar 07 '21 at 19:57
  • @masseyb can you explain a little bit more please? – Michael Nov 02 '22 at 10:24
  • 2
    @Michael has been a minute but e.g. you have the host, docker in docker running on the host, and service A running in `dind` - service A requests a volume mount from `dind`, not the host, the `dind` container will search for the mount within the `dind` layer, not the host layer, if you want to share a host volume to a service running in `dind` then you need to bind-mount the host volume to the `dind` container then service A can request to mount the volume from `dind` (and `dind` will search on it's own host path inside the `dind` container). `dind` is not host aware. – masseyb Nov 02 '22 at 10:34

0 Answers0