Docker-compose does not mount volumes

Hi folks,

I’m having trouble to setup CI with my docker-compose based projects. This is my compose file for a test project:

version: "2"
services:
  api:
    build: .
    command: "npm run demo"
    environment:
      - NODE_ENV=development
    volumes:
      - "${PWD}:/usr/src/app"

But it fails that npm cant find the package.json because the volume under /usr/src/app is missing. You can see the output here:

If I run this compose file localy on my computer it runs fine and outputs hello world.

Any idea what could couse this?

Thanks for your time.

Tim

I solved this myself :smile:.

The reason was very simple: I had to specify the paths on the docker host and not inside of the docker container which was starting the docker container. In the end it is dockerd which starts the container and has to provide the paths.

2 Likes

Hi Tim,

We’ve got exact the same problem! How exactly did you fix it?
We’ve worked hours long to fix this problem, but we cannot figure it out!

Any ideas? Please contact us!

Hi Cees,

Depends on your Problem, my got solved via the configuration file of the runner:

concurrent = 1
check_interval = 0

[[runners]]
  name = ""
  url = ""
  token = ""
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "gitlab/dind:latest"
    privileged = true
    disable_cache = false
    volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock:rw", "/builds:/builds:rw"]
  [runners.cache]
1 Like

Ah dude, awesome! It works!

1 Like

How did you change the volumes? Directly in the .toml file?