Tuesday, January 31, 2017

docker : folder sharing on windows


To share a folder / volume using Docker, you need to understand the layers involved. There are 3 main layers - which are

Host (Your machine) -> Docker (a virtual machine using Oracle VM called default / or your Windows Hypervisor )  -> Image (the image you download from Docker hub for example hello-world or ubuntu.


Virtual machine configuration 

Using Oracle virtual machine, shutdown default virtual machine if it is already running. The click on Properties->Shared Folder->Add your share location as shown below :-

In this example, you're sharing /c/blog -> c:\tmp\laravel\blog


Running the container

Next, we will mount the volume to a container path /var/www/laravel. What's going on is we're trying to mount virtual machine shared folder (indirectly host machine share folder) to a container folder.

docker run -p 8000:80 -p 443:443 -v /c/blog/:/var/www/laravel/ -d eboraas/laravel

I think many people got confused with providing a windows directory here. (-v /c/blog with /c:/tmp/laravel/blog). You need to share your host folder with virtual machine first.

After this command executes, we're have a container with directory.

No comments: