Score:0

Can't bind volume between container and other container (docker-in-docker)

cn flag

I try to setup my gitlab runner on my M1 MacBook for some environment testing. My CI workflow is quite simple : build -> test -> deploy. I use docker executor and for testing tasks I use docker-compose because I have to deploy a database beside the service I want to test.

My CI works perfectly on a EC2 running Ubuntu. But when I tried to run my runner on macOS, my volume ./backend is not bind with /app. I tried to ls /app on backend container and with the EC2 all files and folders are here but not when I run the runner on macOS.

gitlab-ci.yml (this is just the backend_test part:

test_backend:
  stage: test
  needs: ["build_backend_image"]
  image: docker
  services:
    - docker:dind
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
    - mkdir -p $DOCKER_CONFIG/cli-plugins
    - apk add curl
    - curl -SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
    - chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
  script:
    - docker compose -f docker-compose-ci.yml up -d db
    - docker exec db sh mongo_init.sh
    - docker compose -f docker-compose-ci.yml up -d backend
    - pwd
    - ls
    - ls backend
    - docker exec backend pwd
    - docker exec backend ls -l
    - docker exec backend ls / -l
    - docker exec backend pip3 install --no-cache-dir --upgrade -r requirements-test.txt
    - docker exec backend pytest test --junitxml=report.xml -p no:cacheprovider
  interruptible: true
  artifacts:
    when: always
    reports:
      junit: backend/report.xml
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_COMMIT_BRANCH == 'develop'
    - if: $CI_COMMIT_BRANCH == 'master'

gitlab-runner/config.toml:

concurrent = 2
check_interval = 0

[session_server]
  session_timeout = 1800


[[runners]]
  name = "Macbook"
  url = "https://gitlab.com/"
  token = "xxxxxxxxxx"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:20.10.13"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/certs/client", "/cache"]
    shm_size = 0

EC2 runner ls output:

$ docker exec backend ls /app -l
total 36
-rw-rw-rw-  1 root root  285 Jun  3 15:30 Dockerfile
-rw-rw-rw-  1 root root  325 May 20 23:49 DockerfileTest
-rw-rw-rw-  1 root root   48 May 20 23:49 __init__.py
drwxrwxrwx 11 root root 4096 Jun  4 17:17 app
-rw-rw-rw-  1 root root 4286 Jun  4 16:41 favicon.ico
-rw-rw-rw-  1 root root   33 Jun  4 16:41 requirements-test.txt
-rw-rw-rw-  1 root root 1673 Jun  4 16:41 requirements.txt
drwxrwxrwx  6 root root 4096 Jun  4 16:41 test

macOS runner ls output:

$ docker exec backend ls /app -l
total 0

docker-compose-ci.yml:

services:
  backend:
    container_name: backend
    image: $CI_REGISTRY_IMAGE/backend:$CI_COMMIT_SHA
    volumes:
      - ./backend:/app
    networks:
      default:
    ports:
      - 8000:8000
      - 587:587
      - 443:443
    depends_on:
      - db

  db:
    container_name: db
    image: mongo
    volumes:
      - ./mongo_init.sh:/mongo_init.sh:ro
    networks:
      default:
    environment:
      MONGO_INITDB_DATABASE: xxxxxxx
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: admin
    ports:
      - 27017:27017


networks:
  default:
    driver: bridge

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.