Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Automatically mount home directory #202

Closed

Description

@bfirsh

(This is a reopening of boot2docker/boot2docker#84 now that the CLI is a separate project.)

This is related to boot2docker/boot2docker#284. If the boot2docker VM has some way of mounting directories on the host machine, it is pretty useless unless this is exposed somehow in the CLI.

The simplest and most powerful option I can see is automatically mounting your home directory at the same place inside the VM. For example, mounting /Users/ben on OS X at /Users/ben inside the VM. This works brilliantly for Docker volumes, because you can run docker run -v .:/code ... and it Just Works because . expands to /Users/ben/....

It could also mount the entirety of /Users, but I'm not sure on the details of how the permissions would work.

Activity

  1. SvenDowideit commented on Jul 31, 2014

    @SvenDowideit
    Contributor

    NO, we don't want to give the users's private gpg keys to any container that tells the user how it should be run..... with -v $HOME?

    I'm currently working towards auto-sharing ~/docker-share - which makes sure the user is intentional about what they're sharing.

  2. bfirsh commented on Jul 31, 2014

    @bfirsh
    ContributorAuthor

    I'm open to suggestions to how we could make this more secure, but this is how it works if you have Docker installed on Linux. I think we can assume that if you've got access to create containers, you have root access to the host machine.

  3. SvenDowideit commented on Aug 3, 2014

    @SvenDowideit
    Contributor

    Please see the vbox PR for why feature parity with Linux is not a good idea - we do not really want installing Boot2Docker imply that containers have root access on the Desktop.

  4. aanand commented on Aug 4, 2014

    @aanand
    Contributor

    Rather than sharing anything by default, the recommended behaviour could be to individually share specific directories as and when you need to. A typical workflow might go:

    $ cd ~/src
    $ git clone [email protected]:someuser/someproject.git
    $ cd someproject
    $ boot2docker share .
    /Users/aanand/src/someproject is now shared.
    $ docker run -v ~/someproject:/code ...
    

    There'd also be an interface for managing shares:

    $ boot2docker share
    /Users/aanand/src/someproject
    /Users/aanand/src/otherproject
    
    $ boot2docker share -d ~/src/someproject
    /Users/aanand/src/someproject is no longer being shared.
    
  5. nathanleclaire commented on Aug 4, 2014

    @nathanleclaire
    Contributor

    @SvenDowideit raises good point about boot2docker share here: boot2docker/boot2docker#284 (comment) . If we disallow sharing of ~, and provide users with "safe" ~/docker-share directory by default (as well as scream very loudly about security concerns of possibly sharing ~/.ssh etc.), this might be okay.

  6. aanand commented on Aug 4, 2014

    @aanand
    Contributor

    Yeah, I'm on board with not recommending sharing ~, and indeed with disallowing it outright (or at least making it difficult - forcing you to create a ~/.yes-i-really-mean-it-share-me file, for example).

    I meant to say that I was proposing the "share individual directories as needed" recommendation as an alternative to a default ~/docker-share directory. I think it's a bit better from a UX standpoint, as there's no need for an extra load of explanation and inconvenience ("Docker can only see things in ~/docker-share, so please change how you structure your home directory").

    At the same time, we make the step of sharing a directory clear, and still give the user the option of doing everything Docker-related in a single directory if they decide that's more convenient.

  7. SvenDowideit commented on Aug 5, 2014

    @SvenDowideit
    Contributor

    @bfirsh in reply to

    To be clear: sharing your home directory with the virtual machine does not mean arbitrary images have access to anything in your home directory. They have access to what you choose to give them access to in your home directory, in the same way that running Docker on Linux works. E.g. this will only give the container access to files in ~/my-project:
    
    $ docker run -v ~/my-project:/code
    

    this is essentially incorrect. it is way too simple to give a container a docker client that can talk to a docker socket on b2d, and that then allows it to orchestrate the attack on things the user did not give intentionally.

    implementation plan

    I plan on implementing an OSX and Windows (and possibly Linux b2d) functionality in b2d 1.3.0 that will automatically create the default share and wire it up to the vm. this will give users the main thing functionality they seem to need - to have code checked out on their desktop, which they then build and run using the docker vm.

    I use the word default to indicate that there will be a way for knowledgeable users to over-ride this, but what that is, depends on how the implementation pans out (I'm unsure atm what limitations I'll hit wrt user&password passing).

    I'm notionally calling it ~/docker-share as its explicit and obvious - but 'whatever' :)

  8. SvenDowideit commented on Aug 6, 2014

    @SvenDowideit
    Contributor

    @aanand I like the boot2docker share suggestion, though I worry it makes it too easy to shoot someone in the foot. When we get into implementation, we can talk about how easy/hard it gets.

    My initial default is to have one share setup automatically, so new users can use docker run -v /whateverthatis: straight away after they click the blue boot2docker application icon.

  9. tianon commented on Aug 6, 2014

    @tianon
    Contributor

    This is also further complicated by the fact that we're going to be dealing with multiple VM backends very soon. I think it'll be cleanest if backends that don't support shares easily just bail with an error, no matter what way we go as far as implementation goes.

  10. so0k commented on Aug 7, 2014

    @so0k

    cool, so this will no longer be needed then: boot2docker/boot2docker#474 ?

  11. SvenDowideit commented on Aug 8, 2014

    @SvenDowideit
    Contributor

    @so0k (now that I've realised we're talking about the same thing :) ) I'm thinking I might add the option to do it this way around too - as both approaches are important for different uses. Thankyou very much - its feedback like yours that reminds me of things.

  12. so0k commented on Aug 8, 2014

    @so0k

    As everyone agrees in the above discussions, this seems to be one of the main pain points of the community and although you have provided the tools to achieve a workable solution, it seems many still struggled to make it work. putting it in a simple script hopefully helps more people follow docker's recommended best practice. Thank you for all the tools!

  13. ches commented on Aug 8, 2014

    @ches

    I'm 👍 for @aanand's suggestion for the UX arguments he makes for it. I have automation around how I structure and set up projects on my local disk—encrypted disk images for client code checkouts, tmux session config generation, etc. For reasons like this I and other developers get frustrated in a hurry with arbitrary prescribed directory layouts.

    @aanand's suggestion would work fluidly with Fig for a very common development use case such as this kind of fig.yml config with a relative volume mount directive:

    app:
      build: .  # Dockerfile
      command: bundle exec rails server
      ports:
        - 3000:3000
      volumes:
        - .:/apps/myapp
      links:
        - db
    
    # db container, etc.

    The team using boot2docker only needs to remember boot2docker share . before fig up, which IMO is much less onerous than the aforementioned "explanation and inconvenience" of "well actually this will only work if your checkout is somewhere under ~/docker-share...".

    It could even be easy and not particularly distasteful for tools like Fig to detect that boot2docker is in use and give first-class support like an interactive prompt ("It looks like you need to share /this/directory with boot2docker for remote Docker mounting. Share it? [y/n]").

    Of course implementing boot2docker share is more work, but it doesn't preclude it from strongly discouraging users from applying it to $HOME or anything outside it, or sharing ~/docker-share out of the box. It also seems like it offers flexibility as a command line API that can adapt under the hood to changes/improvements in the sharing implementation.

  14. SvenDowideit commented on Aug 11, 2014

    @SvenDowideit
    Contributor

    can I be clear - I'm not worried about the implementation - boot2docker share is trivial to implement and test.

    the only thing I'm worried about is working out how and where I can reduce risk to users that may even be unaware that Boot2Docker in installed and running - If you look around the net, you'll find an awful lot of people that think auto sharing /Users/ is a clever idea - and those people should already know why they're doing it - sadly, anyone else on that shared computer has no idea... and 'oh, I'll just set up my home dir so you can share my music....

    it sounds like we might have an interesting proposal for the Docker project though - if they implement docker run -v .:/data to mean the current dir (atm, only absolute paths are supported), We can then work out how to get Docker to trigger Boot2Docker's to auto-share it. We then need to work out how to garbage collect that share - as Boot2Docker is not aware what is happening to the remote daemon at the moment....

    Please - think about the hard stuff - where the risks are and how to mitigate them - creating a share is trivial.

  15. silenceisgolden commented on Aug 14, 2014

    @silenceisgolden

    @SvenDowideit Isn't the point of boot2docker to be a separate project? If there is some auto-sharing going on I would think that would be a pain point for documentation since it might fall into the "magic", aka user doesn't know what's going on category. At the very least there would need to be a flag to set (maybe just --boot2docker) that would trigger that auto-link, but I would stay away from anything auto-linking automatically. If it was a flag then it would link all directories that were linked in with -v. What do you think? For the near term though, the boot2docker share command that checks to make sure the path is absolute and 3+ levels deep from / would be awesome.

  16. SvenDowideit commented on Aug 15, 2014

    @SvenDowideit
    Contributor

    yup, sorry, I didn't mean to imply that boot2docker share would be gated on a Docker possibility.

  17. SvenDowideit commented on Sep 2, 2014

    @SvenDowideit
    Contributor

    I've written some code to implement boot2docker share using sshfs - #247 - if you build it, it should work with most recent boot2docker iso's.

  18. bfirsh commented on Sep 11, 2014

    @bfirsh
    ContributorAuthor

    boot2docker/boot2docker#534 (also pending a boot2docker-cli change)

  19. added a commit that references this issue on Nov 10, 2014
  20. chirayuk commented on Nov 22, 2014

    @chirayuk

    +1 to everything @SvenDowideit said.  I discovered that I can pass --vbox-share=disable to disable the forced auto-share.  It would be great if this could be read from the profile/config file so that one doesn't have to remember to pass it on the command line.

  21. tianon commented on Feb 26, 2018

    @tianon
    Contributor

    Sorry, this repository is long-since deprecated in favor of Docker Toolbox (whose usage is now also discouraged in favor of Docker for Windows and Docker for Mac).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions