Can’t mount file in gitlab CI with docker-compose

  docker, docker-compose, gitlab-ci

We have a project that uses docker-compose for setup, so we’d like to use the same thing for tests (which we already have prepared and running locally), however I encountered 2 issues with gitlab’s ci

ERROR: for store_k4g_nginx  Cannot start service nginx: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/builds/project/whatever/docker/nginx/nginx.conf" to rootfs at "/var/lib/docker/overlay2/dfff5e2d38c01c8726cbd6fb46a44456521025d6cee3c596a6e56f7992938ce8/merged/etc/nginx/nginx.conf" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

We’re using our own runner with the following configuration

[[runners]]
  name = "******"
  url = "https://gitlab.com/"
  token = "*****"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0

and the ci script looks like this

test:
  image: docker/compose:latest
  stage: test
  variables:
    APP_ENV: test
  before_script:
    - apk add bash ncurses
  script:
    - bash ./scripts/test.sh --no-interaction --compose

the test.sh script brings up the project with docker-compose, which fails because of the error listed on top.
Yes, nginx.conf is a file, it exists and works as expected in a local use of docker-compose.
Another weird thing is that if I removed that line (which only happens for a nginx.conf file, linked to /etc/nginx/nginx.conf) and made it copy said file into the location in dockerfile it boots, but then it cannot see any files if i do ls -la

I believe we’re running the gitlab runner natively and we’ve previously had nginx installed on the server. Could that be an issue? Should we run the runner in a docker as well?

Source: Docker Questions

LEAVE A COMMENT