Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cristhoz/ead7f73fa159a11e51b1c10b20b61f6f to your computer and use it in GitHub Desktop.
Save cristhoz/ead7f73fa159a11e51b1c10b20b61f6f to your computer and use it in GitHub Desktop.

Legend

This is a command in the Docker Quickstart Terminal

$ This is a command run inside the docker host or inside a container (linux etc, eg after docker-machine ssh default or docker run -it ubuntu bash)

Install Docker Toolbox

  1. start docker quick-start terminal

This will create a default vm in VirtualBox

  1. Add shared folder to that via virtualbox ui with Name dev and targeting the local development folder if the folder is not already inside the users home directory on windows

Note: VirtualBox cannot expose hard-linked folders it seems. So in case e.g c:\Development is actually pointing to e.g E:, you should pick E:\ instead.

Content in the C:\Users folder is automatically shared so if your content is located there its not necessary to do anything more as //c/Users/...:/target would already mount whatever ... path as /target in a container and we could skip to step 3.

docker-machine ssh default

Now we are inside the virtual machine which we will to configure to auto-mount the mounted development folder to the virtual machine

$ cd /var/lib/boot2docker

$ sudo vi ./bootsync.sh

Fill with (or append the mdkir and mount lines to existing content):

#!/bin/sh

mkdir /home/docker/dev
mount.vboxsf dev /home/docker/dev

Note: Also see https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md

$ sudo chmod +x ./bootsync.sh

$ exit

docker-machine restart

Verify the mounted folder

docker-machine ssh

$ cd ~/dev

$ ls

Should show the contents of the local development folder target from the virtualbox ui

$ exit

  1. Mount a host path into a container (any folder inside the docker host itself)

Now that a folder is mounted into the docker host, it can be used as a volume to mount in containers

Verification:

docker run -v '//home/docker/dev/test/docker:/project-test' -it ubuntu bash

This would start a new ubuntu container and mount whatever folder VirtualBox was shared at /home/docker/dev with the container at /project-test.

Note: the double / in front of //home is required only to escape the path for msysgit underlying the MINGW64. otherwise it would try to convert the path into a windows path.

Additional information > Commands for mounting from boot2docker vm to windows host

after logging into the host run:

$ mkdir <FOLDER-NAME>
$ mount.vboxsf <NAME-OF-SHARED-FOLDER-IN-VBOX-UI> <FOLDER-NAME>

all other examples i found didnt work :)

@cristhoz
Copy link
Author

cristhoz commented Sep 4, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment