I’m a little late to the Docker party. However, we’re experiencing an increasing number of issues (mostly speed) with our current development environment (VMs), so I really wanted to explore an alternative.

The beauty of Docker, is that we have the speed of the host system for accessing our source code (no more mounted drives), but also, the flexibility of running our stack and swapping out any components we need – don’t want to use Apache anymore? Switch out the container for Nginx, back up and running in minutes.

So, over the Christmas period, I started exploring Docker on Mac, and then, in January, started exploring Docker on Windows.

Access Windows mounted directories directly from within a Docker container

You cannot mount a windows directory from directly within your container, due to the DockerMachine (running as a VM). Whilst you can mount a volume using something like docker run -it -v /docker-data:/data debian bash you can only do this if the /docker-data is within your Users folder – Kitematic will tell you this if you try and add a directory .

So, what if you want to outside of your Users folder? It’s a little more complicated.

Firstly, you’re going to want to close down your Docker VM. Simply open up VirtualBox, find the VM called Default and shut it down.

Navigate to your VirtualBox folder in a command prompt – cd "C:\Program Files\Oracle\VirtualBox"

Next, run the VirtualBox Media Manager and add a new folder to your VM.

VBoxManage sharedfolder add default --name --hostpath "" so, something like: VBoxManage sharedfolder add default --name mydata --hostpath "d:\development\"

mydata is going to be the name of our data folder. So you’ll be able to use whatever name you want here.

Now, start your VM.

Next, you should SSH into your Docker VM. Open up a Docker Terminalm and ssh [email protected]

The default Docker installation login details are:

user: docker
pass: tcuser

Now that you’re on the Docker machine, you need to run the following:

sudo mkdir -p /data
sudo mount -t vboxsf -o "defaults,uid=33,gid=33,rw" mydata /data

Next, we need to tell Docker to mount this every time we start the VM.

sudo vi /mnt/sda1/var/lib/boot2docker/profile

Once you’re editing the file, add the following to the end.

mount -t vboxsf -o "defaults,uid=33,gid=33,rw" mydata /data

Once added, you can then add the volume to any container like so:

docker run --name php56 -p 80:80 -v /data/www/:/var/www/html -d localphp:5.6

Where /data/www/ is actually d:\development\data\

Image Credit: the world on the move