From 01c9f97a6382381a5fca03a042618f28da9957a1 Mon Sep 17 00:00:00 2001 From: Ryan Wynn Date: Tue, 12 Jan 2021 12:52:42 -0500 Subject: [PATCH] linux only: fall back to host networking if gateway IP not found --- src/lambda/handler-runner/docker-runner/DockerContainer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lambda/handler-runner/docker-runner/DockerContainer.js b/src/lambda/handler-runner/docker-runner/DockerContainer.js index 890e6501c..fcfd0ca62 100644 --- a/src/lambda/handler-runner/docker-runner/DockerContainer.js +++ b/src/lambda/handler-runner/docker-runner/DockerContainer.js @@ -135,7 +135,12 @@ export default class DockerContainer { // Add `host.docker.internal` DNS name to access host from inside the container // https://github.com/docker/for-linux/issues/264 const gatewayIp = await this._getBridgeGatewayIp() - dockerArgs.push('--add-host', `host.docker.internal:${gatewayIp}`) + if (!!gatewayIp) { + dockerArgs.push('--add-host', `host.docker.internal:${gatewayIp}`) + } else { + // fall back to host networking if gateway IP not found + dockerArgs.push('--network', 'host') + } } const { stdout: containerId } = await execa('docker', [