dockerdocker-compose

Mounted volume is empty inside container


I've got a docker-compose.yml like this:

db:
  image: mongo:latest
  ports:
    - "27017:27017"
server:
  image: artificial/docker-sails:stable-pm2
  command: sails lift
  volumes:
    - server/:/server
  ports:
    - "1337:1337"
  links:
    - db

server/ is relative to the folder of the docker-compose.yml file. However when I docker exec -it CONTAINERID /bin/bash and check /server it is empty.

What am I doing wrong?


Solution

  • Try using:

    volumes:
      - ./server:/server
    

    instead of server/ -- there are some cases where Docker doesn't like the trailing slash.