Docker-compose not mounting volumes in main gitlab CI container

Hi,

I am a newbie who is struggling with the CI process in gitlab. Namely, I am unable to mount a volume in docker-compose. Hope somebody can help!

I am starting a docker-compose process from within a gitlab CI job and am using the docker-in-docker executor configuration from gitlab docs.

services:
  - name: registry.gitlab.com/plantoeducate/devops/dind-git/dind-git
    alias: docker
  - name: registry.gitlab.com/plantoeducate/api-db:latest
    alias: postgres

build:
    - docker-compose -f docker-compose.yaml -f docker-compose.test.yaml --verbose up

The docker-compose file contains a volume mount:

  tusd:
    .....
    env_file:
      - ./config/.tusd.test.env
    volumes:
    - $PWD/certs:/server/certs

From within the gitlab CI process I can issue an ls command and successfully view the contents of $PWD/certs. However, when the docker-compose process starts up the container, the files are not mounted in /server/certs.

Does anyone have any idea why files do not seem to be mounted in /server/certs in the container? I have tested the docker-compose on local machine and it works fine. It does not seem to mount from within a build container! Any ideas?

Updated with solution
After reading another forum post solved the issue. In summary, volumes must be linked from source directories inside project dir, i.e. $CI_PROJECT_DIR.

1 Like