Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 807
evanmcd Avatar asked Jan 24 '26 06:01

evanmcd


1 Answers

There are many ways to do it, and one of the easier ways is:

Step 1: Make sure Docker.app has an entry for that folder/volume

enter image description here

Step 2: Mount it with the -v flag and the path to that folder:

docker run --link cockroachdb -v /Users/gajensunthara/backups:/Users/gajensunthara/backups -it --rm --name backup-restore backup-restore
like image 90
Gajen Sunthara Avatar answered Jan 26 '26 20:01

Gajen Sunthara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!