Skip to content

Commit b2c9366

Browse files
committed
Add the --virtualbox-host-dns-resolver flag
Signed-off-by: Joe Friedl <joe@joefriedl.net>
1 parent ee53083 commit b2c9366

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/drivers/virtualbox.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Options:
2626
- `--virtualbox-memory`: Size of memory for the host in MB.
2727
- `--virtualbox-cpu-count`: Number of CPUs to use to create the VM. Defaults to single CPU.
2828
- `--virtualbox-disk-size`: Size of disk for the host in MB.
29+
- `--virtualbox-host-dns-resolver`: Use the host DNS resolver. (Boolean value, defaults to false)
2930
- `--virtualbox-boot2docker-url`: The URL of the boot2docker image. Defaults to the latest available version.
3031
- `--virtualbox-import-boot2docker-vm`: The name of a Boot2Docker VM to import.
3132
- `--virtualbox-hostonly-cidr`: The CIDR of the host only adapter.
@@ -67,6 +68,7 @@ Environment variables and default values:
6768
| `--virtualbox-memory` | `VIRTUALBOX_MEMORY_SIZE` | `1024` |
6869
| `--virtualbox-cpu-count` | `VIRTUALBOX_CPU_COUNT` | `1` |
6970
| `--virtualbox-disk-size` | `VIRTUALBOX_DISK_SIZE` | `20000` |
71+
| `--virtualbox-host-dns-resolver` | `VIRTUALBOX_HOST_DNS_RESOLVER` | `false` |
7072
| `--virtualbox-boot2docker-url` | `VIRTUALBOX_BOOT2DOCKER_URL` | _Latest boot2docker url_ |
7173
| `--virtualbox-import-boot2docker-vm` | `VIRTUALBOX_BOOT2DOCKER_IMPORT_VM` | `boot2docker-vm` |
7274
| `--virtualbox-hostonly-cidr` | `VIRTUALBOX_HOSTONLY_CIDR` | `192.168.99.1/24` |

docs/reference/create.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ invoking the `create` help text.
9797
--virtualbox-boot2docker-url The URL of the boot2docker image. Defaults to the latest available version [$VIRTUALBOX_BOOT2DOCKER_URL]
9898
--virtualbox-cpu-count "1" number of CPUs for the machine (-1 to use the number of CPUs available) [$VIRTUALBOX_CPU_COUNT]
9999
--virtualbox-disk-size "20000" Size of disk for host in MB [$VIRTUALBOX_DISK_SIZE]
100+
--virtualbox-host-dns-resolver Use the host DNS resolver [$VIRTUALBOX_HOST_DNS_RESOLVER]
100101
--virtualbox-dns-proxy Proxy all DNS requests to the host [$VIRTUALBOX_DNS_PROXY]
101102
--virtualbox-hostonly-cidr "192.168.99.1/24" Specify the Host Only CIDR [$VIRTUALBOX_HOSTONLY_CIDR]
102103
--virtualbox-hostonly-nicpromisc "deny" Specify the Host Only Network Adapter Promiscuous Mode [$VIRTUALBOX_HOSTONLY_NIC_PROMISC]

drivers/virtualbox/virtualbox.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type Driver struct {
5252
DiskSize int
5353
Boot2DockerURL string
5454
Boot2DockerImportVM string
55+
HostDNSResolver bool
5556
HostOnlyCIDR string
5657
HostOnlyNicType string
5758
HostOnlyPromiscMode string
@@ -110,6 +111,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
110111
Value: defaultBoot2DockerImportVM,
111112
EnvVar: "VIRTUALBOX_BOOT2DOCKER_IMPORT_VM",
112113
},
114+
mcnflag.BoolFlag{
115+
Name: "virtualbox-host-dns-resolver",
116+
Usage: "Use the host DNS resolver",
117+
EnvVar: "VIRTUALBOX_HOST_DNS_RESOLVER",
118+
},
113119
mcnflag.StringFlag{
114120
Name: "virtualbox-hostonly-cidr",
115121
Usage: "Specify the Host Only CIDR",
@@ -179,6 +185,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
179185
d.SwarmDiscovery = flags.String("swarm-discovery")
180186
d.SSHUser = "docker"
181187
d.Boot2DockerImportVM = flags.String("virtualbox-import-boot2docker-vm")
188+
d.HostDNSResolver = flags.Bool("virtualbox-host-dns-resolver")
182189
d.HostOnlyCIDR = flags.String("virtualbox-hostonly-cidr")
183190
d.HostOnlyNicType = flags.String("virtualbox-hostonly-nictype")
184191
d.HostOnlyPromiscMode = flags.String("virtualbox-hostonly-nicpromisc")
@@ -309,6 +316,11 @@ func (d *Driver) Create() error {
309316
cpus = 32
310317
}
311318

319+
hostDNSResolver := "off"
320+
if d.HostDNSResolver {
321+
hostDNSResolver = "on"
322+
}
323+
312324
dnsProxy := "off"
313325
if d.DNSProxy {
314326
dnsProxy = "on"
@@ -326,7 +338,7 @@ func (d *Driver) Create() error {
326338
"--acpi", "on",
327339
"--ioapic", "on",
328340
"--rtcuseutc", "on",
329-
"--natdnshostresolver1", "off",
341+
"--natdnshostresolver1", hostDNSResolver,
330342
"--natdnsproxy1", dnsProxy,
331343
"--cpuhotplug", "off",
332344
"--pae", "on",

0 commit comments

Comments
 (0)