From 728582d7e51b744ed5c27c42260a513fe9769ca0 Mon Sep 17 00:00:00 2001 From: Tetsuro Aoki Date: Fri, 28 Oct 2022 21:27:42 +0900 Subject: [PATCH] fix: prevent overwriting host.docker.internal in wsl --- package-lock.json | 1 + package.json | 1 + src/lambda/handler-runner/docker-runner/DockerContainer.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 6240e3ce3..e521316a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "chalk": "^5.1.2", "execa": "^6.1.0", "fs-extra": "^10.1.0", + "is-wsl": "^2.2.0", "java-invoke-local": "0.0.6", "jose": "^4.10.3", "js-string-escape": "^1.0.1", diff --git a/package.json b/package.json index 63b1d9f38..dcdf3c688 100644 --- a/package.json +++ b/package.json @@ -91,6 +91,7 @@ "chalk": "^5.1.2", "execa": "^6.1.0", "fs-extra": "^10.1.0", + "is-wsl": "^2.2.0", "java-invoke-local": "0.0.6", "jose": "^4.10.3", "js-string-escape": "^1.0.1", diff --git a/src/lambda/handler-runner/docker-runner/DockerContainer.js b/src/lambda/handler-runner/docker-runner/DockerContainer.js index 63c162638..b9841a9c6 100644 --- a/src/lambda/handler-runner/docker-runner/DockerContainer.js +++ b/src/lambda/handler-runner/docker-runner/DockerContainer.js @@ -9,6 +9,7 @@ import { execa } from 'execa' import { ensureDir, pathExists } from 'fs-extra' import jszip from 'jszip' import pRetry from 'p-retry' +import isWsl from 'is-wsl' import DockerImage from './DockerImage.js' const { stringify } = JSON @@ -148,7 +149,7 @@ export default class DockerContainer { dockerArgs.push('-e', `${key}=${value}`) }) - if (platform() === 'linux') { + if (platform() === 'linux' && !isWsl) { // 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()