Search code examples
ubuntudockerdocker-machine

Docker host volume is empty after mounted


I am using Docker-CE (version 17.09) on Ubuntu 16.04 host. I used docker-machine (version 0.12.2) to create docker machine for running containers.

I am trying out mounting host volume to container. However, the mounted volume is empty inside container, while that folder is not empty on host. This is the command I used:

docker run -p 80:80 -v /home/modeller/ExpressSite:/var/test kitematic/hello-world-nginx

What could be the cause of this issue?

-- Also one side question: does docker have a preference of Mac and Windows OS over Ubuntu OS? I found large number of tutorials for Mac and Windows, but few wrote about Ubuntu OS.


Solution

  • The problem you are seeing is that the directory(ies) you are trying to mount, they are mounted from your docker machine (VirtualBox) ones.

    I would suggest that you share /home/modeller/ExpressSite with your docker-machine from Settings->Shared Folders and then try running the container again.

    To answer to your second question, I don't think there's a preference, just that many people are using Mac & Windows and CentOS / Debian as their base OS.