You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 27, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 27, 2018. It is now read-only.
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.
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.
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.
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.
@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.
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.
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' :)
@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.
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.
@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.
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!
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: . # Dockerfilecommand: bundle exec rails serverports:
- 3000:3000volumes:
- .:/apps/myapplinks:
- 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.
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.
@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.
+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.
Activity
SvenDowideit commentedon Jul 31, 2014
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.bfirsh commentedon Jul 31, 2014
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.
SvenDowideit commentedon Aug 3, 2014
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.
aanand commentedon Aug 4, 2014
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:
There'd also be an interface for managing shares:
nathanleclaire commentedon Aug 4, 2014
@SvenDowideit raises good point about
boot2docker sharehere: boot2docker/boot2docker#284 (comment) . If we disallow sharing of~, and provide users with "safe"~/docker-sharedirectory by default (as well as scream very loudly about security concerns of possibly sharing~/.sshetc.), this might be okay.aanand commentedon Aug 4, 2014
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-mefile, for example).I meant to say that I was proposing the "share individual directories as needed" recommendation as an alternative to a default
~/docker-sharedirectory. 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.
SvenDowideit commentedon Aug 5, 2014
@bfirsh in reply to
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-shareas its explicit and obvious - but 'whatever' :)SvenDowideit commentedon Aug 6, 2014
@aanand I like the
boot2docker sharesuggestion, 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.
tianon commentedon Aug 6, 2014
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.
so0k commentedon Aug 7, 2014
cool, so this will no longer be needed then: boot2docker/boot2docker#474 ?
SvenDowideit commentedon Aug 8, 2014
@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.
so0k commentedon Aug 8, 2014
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!
ches commentedon Aug 8, 2014
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.ymlconfig with a relative volume mount directive:The team using boot2docker only needs to remember
boot2docker share .beforefig 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 shareis more work, but it doesn't preclude it from strongly discouraging users from applying it to$HOMEor anything outside it, or sharing~/docker-shareout 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.SvenDowideit commentedon Aug 11, 2014
can I be clear - I'm not worried about the implementation -
boot2docker shareis 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 .:/datato 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.
silenceisgolden commentedon Aug 14, 2014
@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, theboot2docker sharecommand that checks to make sure the path is absolute and 3+ levels deep from/would be awesome.SvenDowideit commentedon Aug 15, 2014
yup, sorry, I didn't mean to imply that
boot2docker sharewould be gated on a Docker possibility.SvenDowideit commentedon Sep 2, 2014
I've written some code to implement
boot2docker shareusing sshfs - #247 - if you build it, it should work with most recent boot2docker iso's.bfirsh commentedon Sep 11, 2014
boot2docker/boot2docker#534 (also pending a boot2docker-cli change)
Merge pull request boot2docker#202 from SvenDowideit/update-tcp-port
chirayuk commentedon Nov 22, 2014
+1 to everything @SvenDowideit said. I discovered that I can pass
--vbox-share=disableto 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.tianon commentedon Feb 26, 2018
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).