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

Added option to disable virtualbox vbfs mount of users home directory #1622

Merged
merged 1 commit into from
Aug 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/drivers/virtualbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Create machines locally using [VirtualBox](https://www.virtualbox.org/).
This driver requires VirtualBox to be installed on your host.

$ docker-machine create --driver=virtualbox vbox-test

You can create an entirely new machine or you can convert a Boot2Docker VM into
a machine by importing the VM. To convert a Boot2Docker VM, you'd use the following
command:
Expand All @@ -29,6 +29,7 @@ Options:
- `--virtualbox-boot2docker-url`: The URL of the boot2docker image. Defaults to the latest available version.
- `--virtualbox-import-boot2docker-vm`: The name of a Boot2Docker VM to import.
- `--virtualbox-hostonly-cidr`: The CIDR of the host only adapter.
- `--virtualbox-no-share`: Disable the mount of your home directory

The `--virtualbox-boot2docker-url` flag takes a few different forms. By
default, if no value is specified for this flag, Machine will check locally for
Expand All @@ -49,11 +50,11 @@ using the `http://` form.

To customize the host only adapter, you can use the `--virtualbox-hostonly-cidr`
flag. This will specify the host IP and Machine will calculate the VirtualBox
DHCP server address (a random IP on the subnet between `.1` and `.25`) so
DHCP server address (a random IP on the subnet between `.1` and `.25`) so
it does not clash with the specified host IP.
Machine will also specify the DHCP lower bound to `.100` and the upper bound
to `.254`. For example, a specified CIDR of `192.168.24.1/24` would have a
DHCP server between `192.168.24.2-25`, a lower bound of `192.168.24.100` and
DHCP server between `192.168.24.2-25`, a lower bound of `192.168.24.100` and
upper bound of `192.168.24.254`.

Environment variables and default values:
Expand All @@ -66,3 +67,4 @@ Environment variables and default values:
| `--virtualbox-boot2docker-url` | `VIRTUALBOX_BOOT2DOCKER_URL` | *Latest boot2docker url* |
| `--virtualbox-import-boot2docker-vm` | - | `boot2docker-vm` |
| `--virtualbox-hostonly-cidr` | `VIRTUALBOX_HOSTONLY_CIDR` | `192.168.99.1/24` |
| `--virtualbox-no-share` | - | `false` |
9 changes: 8 additions & 1 deletion drivers/virtualbox/virtualbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Driver struct {
Boot2DockerURL string
Boot2DockerImportVM string
HostOnlyCIDR string
NoShare bool
}

func init() {
Expand Down Expand Up @@ -91,6 +92,10 @@ func GetCreateFlags() []cli.Flag {
Value: defaultHostOnlyCIDR,
EnvVar: "VIRTUALBOX_HOSTONLY_CIDR",
},
cli.BoolFlag{
Name: "virtualbox-no-share",
Usage: "Disable the mount of your home directory",
},
}
}

Expand Down Expand Up @@ -137,6 +142,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.SSHUser = "docker"
d.Boot2DockerImportVM = flags.String("virtualbox-import-boot2docker-vm")
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
d.NoShare = flags.Bool("virtualbox-no-share")

return nil
}
Expand Down Expand Up @@ -307,7 +313,8 @@ func (d *Driver) Create() error {
// TODO "linux"
}

if shareDir != "" {
if shareDir != "" && !d.NoShare {
log.Debugf("setting up shareDir")
if _, err := os.Stat(shareDir); err != nil && !os.IsNotExist(err) {
return err
} else if !os.IsNotExist(err) {
Expand Down