Skip to content

Instantly share code, notes, and snippets.

@mrhanlon
Last active February 1, 2023 08:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrhanlon/ad857072dc53961b11612a751568783f to your computer and use it in GitHub Desktop.
Save mrhanlon/ad857072dc53961b11612a751568783f to your computer and use it in GitHub Desktop.

Mount the remote volume through whatever means. Example, sshfs:

sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa <remote_user>@host:/path/to/mount /path/to/mount

Stop the machine and add the new shared folder to the VirtualBox config.

docker-machine stop <machine name>
VBoxManage sharedfolder add <machine name> --name /path/to/mount --hostpath path/to/mount --automount
docker-machine start <machine name>
docker-machine ssh <machine name>

Edit or create the file /var/lib/boot2docker/bootlocal.sh with the contents:

mkdir -p /path/to/mount
mount -t vboxsf -o uid=<uid>,gid=<gid> /path/to/mount /path/to/mount

Set <uid> and <gid> to the uid/gid of the user you ultimately want the mount to appear as in containers.

Restart the docker machine. Start a docker container with a volume mount of /path/to/mount.

Enjoy.

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