{"id":1647,"date":"2015-12-21T23:00:16","date_gmt":"2015-12-22T04:00:16","guid":{"rendered":"http:\/\/unitstep.net\/?p=1647"},"modified":"2015-12-22T22:01:11","modified_gmt":"2015-12-23T03:01:11","slug":"accessing-the-host-filesystem-from-a-docker-container-on-os-x-or-windows","status":"publish","type":"post","link":"https:\/\/unitstep.net\/blog\/2015\/12\/21\/accessing-the-host-filesystem-from-a-docker-container-on-os-x-or-windows\/","title":{"rendered":"Accessing the host file system from a Docker container on OS X or Windows"},"content":{"rendered":"
Mounting (or sharing) a directory from the Docker daemon host into a container is simple enough. Example:<\/p>\n
$ docker run -v [host directory path]:[container directory path] -it [image name]<\/code><\/pre>\nHowever, on OS X and Windows, the Docker daemon (currently) runs inside of a Linux VM, that by default is run using VirtualBox. (Since Docker only runs natively on Linux) So, you’d be mounting a folder from the Linux VM<\/em>, which is probably not what you want if you want to share files from your host machine into the container.<\/p>\n<\/p>\n
Thankfully, VirtualBox allows sharing of folders from your host machine into the VM where the Docker daemon resides. The Docker Linux VM is also auto-configured to mount either \/Users<\/code> (OS X) or C:\\Users<\/code> (Windows) into \/Users<\/code> on the Linux VM:<\/p>\n\n\n<\/p>\n
This means we can mount \/Users<\/code> from the Linux VM into a container, allowing it access to your underlying host\/physical system’s files in \/Users<\/code> (OS X) or C:\\Users<\/code> (Windows).<\/p>\n