Search code examples
macosdockervirtualboxvirtualization

How to share a folder between my Mac and a Docker container


Been spending some time trying to setup a Docker container with access to a folder on my Mac.

I know that you can use Docker Volumes to connect to a folder in the host, which on Mac ends up being Linux in VirtualBox, with the -v argument to docker run.

And given that, I figured that I could setup a shared folder in VirtualBox, which could then be mapped to the Docker container.

However, I've not been able to get the Shared Folder I've added to VB to show up.

Here's what I've done:

1) Added a Shared Folder in the VB admin

VirtualBox Shared Folder config

2) Restarted the VB OS with both docker-machine restart and via the VB app itself

3) Logged into the VB OS via docker-machine ssh

4) Did an ls -l of the root directory

The Users folder (which was there already in VB) shows up, but the folder I added (Projects) does not.

I can't figure out any reason why both folders would not appear. Anyone else having this problem?

Seems like with so many people talking about doing local Development with Docker, and so many devs using Macs, this would be a simple problem. But... alas...not for me so far.

Thanks for any help.


Solution

  • You should use Docker for Mac. No VirtualBox required and the filesystem access is a lot more natural as well.

    More details at https://www.docker.com/products/docker#/mac.