Skip to content
This repository has been archived by the owner on Jan 1, 2021. It is now read-only.

VirtualBox Guest Additions #534

Merged
merged 2 commits into from
Sep 15, 2014
Merged

Conversation

tianon
Copy link
Contributor

@tianon tianon commented Sep 11, 2014

To provide some context about why this is being reintroduced despite so many expressed reservations, "boot2docker" currently is essentially the "Docker daemon for Mac OS / Windows". On Mac OS at least, where we have a native Docker client, the experience of talking to your "Docker daemon" currently lacks the ability to bind mount files, which causes a lot of problems including fig not working as it should. This is being pushed as a simple stopgap solution to that specific problem while other more sustainable solutions are developed in Docker itself (such as is proposed in moby/moby#7249).

This builds upon the work in #284. Also, this includes a hacky init script that @bfirsh gets to take all the credit for that tries to mount /Users and/or /c/Users, since we can't run VBoxService proper (thanks to hairy issues with 32bit userspace of TCL; good times). The init script will bail quickly and quietly on non-VirtualBox machines or on VirtualBox machines that don't have one of those two shares.

This has been tested on Linux, Mac OS X, and Windows.

If you'd like to test it out without any changes to boot2docker-cli, use:

  • Mac OS X: VBoxManage sharedfolder add boot2docker-vm --name /Users --hostpath /Users --automount
  • Windows: VBoxManage.exe sharedfolder add boot2docker-vm --name /c/Users --hostpath C:/Users --automount (note that this will NOT WORK from inside the msys bash shell because of http://www.mingw.org/wiki/Posix_path_conversion - you must either run it from cmd directly, or create the share of C:\Users named as /c/Users manually)

This will make it so that things like docker run -v "$(pwd)":/some/container/path ... work as you'd expect from Mac OS, and also so that the /Users or /c/Users directory is available for easy access when you boot2docker ssh into your VM.

As a side note, if anyone has ideas for how to disable or prevent that msys path conversion from happening without linking against msys.dll, please please please let me know (I can't find anything useful).

@sfitts
Copy link

sfitts commented Sep 11, 2014

I've run into the msys auto-conversion thing myself and the only thing I've found is that if you add an extra / to the path it should prevent the conversion (though you end up with both slashes, so sometimes that doesn't really help). Not sure if trick will work here, but it might be worth a shot (I'll try it out myself at some point, but that won't be for a bit due to other work priorities).

Oh -- and thanks for resurrecting this. I know it is controversial, but it really does make life for those of us working on Windows a lot nicer (the lack of a native Docker client there gives us a few more issues than our Mac brethren).

@SvenDowideit
Copy link
Contributor

Where's the Documentation?

@tianon
Copy link
Contributor Author

tianon commented Sep 11, 2014

Fair point - I'll write up something. 👍

mkdir -p $ROOTFS/sbin && \
cp x86/lib/VBoxGuestAdditions/mount.vboxsf $ROOTFS/sbin/ && \
\
cd / && rm -rf /vboxguest

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@dduportal
Copy link
Contributor

That's a good job !

One point to (maybe?) help you : while it's perfectly working with vagrant (see my custom vagrant image, based on the previous work - http://vagrantup.com/dduportal/boot2docker), we should throw an eye on how vagrant did it on Windows ?

@tianon
Copy link
Contributor Author

tianon commented Sep 12, 2014

Just as an update, I was dealing with some ill family today. I've updated the technical bits here, but hope to get some docs done tomorrow.

@tianon tianon force-pushed the vbox-guest-additions branch 4 times, most recently from 8389685 to ef06a84 Compare September 13, 2014 20:34
@tianon
Copy link
Contributor Author

tianon commented Sep 13, 2014

Ok, this has some basic documentation now, too. 👍

It is also important to note that in the future, the plan is to have any share
which is created in VirtualBox with the "automount" flag turned on be mounted
during boot at the directory of the share name (ie, a share named `home/jsmith`
would be automounted at `/home/jsmith`).

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@SvenDowideit
Copy link
Contributor

This PR is only missing some documentation to say that it does not work for Linux - even if you share /home as Users, it will then be mounted in the wrong place, and the -v $(pwd):/data will thus fail.

once that's done - LTGM

…che-ability)

Also, this includes a hacky init script that bfirsh gets to take all the credit for that tries to mount `/Users` and/or `/c/Users`, since we can't run `VBoxService` proper (thanks to hairy issues with 32bit userspace of TCL; good times).
@tianon
Copy link
Contributor Author

tianon commented Sep 15, 2014

Ok, I've updated with a paragraph about the nonexistent Linux support: (copied here for easier review)

In case it isn't already clear, the Linux host support here is currently hazy.
You can share your /home or /home/jsmith directory as Users or one of the
other supported automount locations listed above, but note that you will then
need to manually convert your docker run -v /home/...:... bind-mount host
paths accordingly (ie, docker run -v /Users/...:...). As noted in the
previous paragraph however, this is likely to change in the future as soon as a
more suitable/scalable solution is found and implemented.

@SvenDowideit
Copy link
Contributor

LGTM - will there be a b2d-cli PR to set these up?

@tianon
Copy link
Contributor Author

tianon commented Sep 15, 2014

Yeah, that's the plan - I've been working on that on the side while this one got some review. 😄

tianon added a commit that referenced this pull request Sep 15, 2014
@bfirsh
Copy link
Contributor

bfirsh commented Sep 25, 2014

UI is here: boot2docker/boot2docker-cli#258

This will be in the next official release.

@razic
Copy link

razic commented Sep 28, 2014

Wow this actually made it in?

@stevepereira
Copy link

Is this release waiting to sync with the next Docker release?

@tianon
Copy link
Contributor Author

tianon commented Sep 30, 2014

Yes, boot2docker releases are synced to Docker releases, so this will be in
1.3 or 1.2.1, whichever comes first.

@gansbrest
Copy link

VirtualBox Guest Additions are unusable/slow for project with lots of small files ( tested with 17K files ). Is it just me?

I created Hodor github.com/gansbrest/hodor to streamline dev workflow for Mac and Linux. Let me know what you guys think.

@SchumacherFM
Copy link

Nice work @gansbrest !
Sounds like a great solution as we are using Magento with the same amount of files and it is so slow via shared folders ...

But I don't like Ruby so I'm gonna to rewrite it in Go. I also need the sync on Windows :-(
Go has a library for cross plattform sync: https://github.com/howeyc/fsnotify no idea if that works well....

@AkeemMcLennon
Copy link

Hmm, @gansbrest and @SchumacherFM bring up some interesting points and ideas.

However, since these changes are ultimately intended for the fig project, perhaps it might be useful to integrate this filesystem monitoring into Fig directly?

@bfirsh
Copy link
Contributor

bfirsh commented Oct 6, 2014

You might be interested in docker/compose#184

@huahaiy
Copy link

huahaiy commented Oct 8, 2014

These changes should be independent from Fig. The results of Fig's monitoring filesystem change is to rebuild and reload the container, but that may be too expensive. People often prefer to use their development environment's own system reloading mechanism, e.g. Clojure's lein-ring, etc. boot2docker should support these use cases.

@SvenDowideit
Copy link
Contributor

@huahaiy there is nothing in these changes that are dependant on fig - there are comanion changes in boot2docker-cli to make it work. - if you read @AkeemMcLennon 's comment, it asks about integrating this change into fig :)

@gansbrest
Copy link

Sorry guys, I'm not too familiar with fig. From the brief look, Hodor seem to follow similar concepts ( define config and run task ). You may probably take and integrate file sync/forwarding parts. I just wanted to create simple tool to allow our team to do develop in the docker environment efficiently.

@dekz
Copy link

dekz commented Oct 11, 2014

Correct me if I am wrong but no longer have to build from source (as per @sciutand comment) for this support, you can just curl the iso and use that.

http://static.dockerfiles.io/boot2docker-v1.2.0-virtualbox-guest-additions-v4.3.14.iso

@tianon
Copy link
Contributor Author

tianon commented Oct 11, 2014

That ISO isn't an official release. ;)

@dekz
Copy link

dekz commented Oct 11, 2014

Oh maybe I misunderstood based on the URL.

Would you say one should follow the original @sciutand advice in building and copying the ISO over then?

@gaastonsr
Copy link

If the above ISO works why not use it?

@abilash222
Copy link

the above ISO is not working. /User directory is not mounted

@dekz
Copy link

dekz commented Oct 14, 2014

@abilash222 did you use VBoxManage to share the folder into boot2docker?

@vmaatta
Copy link

vmaatta commented Oct 21, 2014

Ok so folders on the Mac host (under $HOME) can now be shared with the container… and you can do nothing with them:

Operation not permitted, Permission denied, could not create directory

I've tried chowning them to 999:999, changed folder rights to 777… and still, those volume folders are just as unusable from the container.

E.g. -v ($HOME)/projects/data/db/:/var/lib/postgresql/data/

@michaelneale
Copy link
Contributor

@vmaatta I ran `docker -it -v /Users:/Users ubuntu:14.04 /bin/bash' and was able to ls and cat files from my him dir just fine - this is stock Docker 1.3

@vmaatta
Copy link

vmaatta commented Oct 21, 2014

Ok, say:

  1. docker run -v /Users/vmaatta/test:/tmp/test -it --rm debian:latest bash: I can manually read, write files and create folders in the container.
  2. I make the same folder a data volume for a postgres /var/lib/postgresql/data and here's the result:
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... initdb: could not create directory "/var/lib/postgresql/data/global": Permission denied
initdb: removing contents of data directory "/var/lib/postgresql/data"

The same with a different container, a web server that needs to write all kinds of files, they both fail with the aforementioned access problems.

@vmaatta
Copy link

vmaatta commented Oct 21, 2014

And it seems there's an issue for it… #581. The release notes are really quite misleading / missing an important note.

@huahaiy
Copy link

huahaiy commented Oct 23, 2014

@vmaatta I seem to be able to run postgres container just fine on boot2docker, see my Postgres Dockerfile here. initdb run as the user postgres, so make sure that user have permission on the $PGDATA directory.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet