Docker Community Forums

Share and learn in the Docker community.

Mounted host volumes are empty

beta

(Kidalex) #1

I’m trying to mount a volume from my host into a container but it is empty. Am I doing something wrong or could this be a bug? Detailed reproduction instructions at the bottom.

Expected behavior

Mounted volume inside container contains the same data as the host

Actual behavior

Mounted volume inside container is empty

Information

Docker for Mac: version: mac-v1.12.0-beta20
OS X: version 10.11.6 (build: 15G7b)
logs: /tmp/20160726-095256.tar.gz
[OK]     docker-cli
[OK]     app
[OK]     moby-syslog
[OK]     virtualization
[OK]     menubar
[OK]     system
[OK]     osxfs
[OK]     db
[OK]     slirp
[OK]     moby-console
[OK]     logs
[OK]     vmnetd
[OK]     env
[OK]     moby
[OK]     driver.amd64-linux

Steps to reproduce the behavior

  1. mkdir -p project/server && touch foobar.txt
  2. Put this docker-compose.yml in project:
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
  1. docker-compose up
  2. docker ps # to get CONTAINER ID
  3. docker exec CONTAINER ID ls -l /server

(David Maze) #2

I think in current Docker Compose this mounts the root directory of the volume named “server”. Does changing this to "./server:/server" work?


(Kidalex) #3

Yes, it does indeed. How could I not think about that myself.