Skip to content

Commit

Permalink
linux only: fall back to host networking if gateway IP not found
Browse files Browse the repository at this point in the history
  • Loading branch information
rwynn committed Jan 12, 2021
1 parent b74f49d commit 01c9f97
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lambda/handler-runner/docker-runner/DockerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down

0 comments on commit 01c9f97

Please sign in to comment.