diff options
author | Arko Dasgupta <arko.dasgupta@docker.com> | 2019-11-01 17:09:40 -0700 |
---|---|---|
committer | Arko Dasgupta <arko.dasgupta@docker.com> | 2020-01-22 13:30:00 -0800 |
commit | 92e809a6807210a3d1ecd7949314367e82f5b683 (patch) | |
tree | 3e301b8be5cb3748e1ffd892d27144a435c9c4bc /integration/internal | |
parent | de5a67156b5eed287883958b60b0c08dacfc7332 (diff) | |
download | docker-92e809a6807210a3d1ecd7949314367e82f5b683.tar.gz |
Support host.docker.internal in dockerd on Linux
Docker Desktop (on MAC and Windows hosts) allows containers
running inside a Linux VM to connect to the host using
the host.docker.internal DNS name, which is implemented by
VPNkit (DNS proxy on the host)
This PR allows containers to connect to Linux hosts
by appending a special string "host-gateway" to --add-host
e.g. "--add-host=host.docker.internal:host-gateway" which adds
host.docker.internal DNS entry in /etc/hosts and maps it to host-gateway-ip
This PR also add a daemon flag call host-gateway-ip which defaults to
the default bridge IP
Docker Desktop will need to set this field to the Host Proxy IP
so DNS requests for host.docker.internal can be routed to VPNkit
Addresses: https://github.com/docker/for-linux/issues/264
Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
Diffstat (limited to 'integration/internal')
-rw-r--r-- | integration/internal/container/ops.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/integration/internal/container/ops.go b/integration/internal/container/ops.go index b9ba8c4e85..c829ad1717 100644 --- a/integration/internal/container/ops.go +++ b/integration/internal/container/ops.go @@ -180,3 +180,11 @@ func WithCgroupnsMode(mode string) func(*TestContainerConfig) { c.HostConfig.CgroupnsMode = containertypes.CgroupnsMode(mode) } } + +// WithExtraHost sets the user defined IP:Host mappings in the container's +// /etc/hosts file +func WithExtraHost(extraHost string) func(*TestContainerConfig) { + return func(c *TestContainerConfig) { + c.HostConfig.ExtraHosts = append(c.HostConfig.ExtraHosts, extraHost) + } +} |