Skip to content

Commit be15c8d

Browse files
committed
Reduce requests required to check that Docker tunnel is running
Previously we checked on the image and then always checked on the container too. Now, in the very common case where the container is already running, we just check that and call it a day (we should never need to pull the image if the container is already running anyway).
1 parent 7f730c2 commit be15c8d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/interceptors/docker/docker-tunnel-proxy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ export function ensureDockerTunnelRunning(proxyPort: number) {
4747
ongoingEnsureTunnelRunningChecks[proxyPort] = containerMutex.runExclusive(async () => {
4848
const docker = new Docker();
4949

50-
// Make sure we have the image available (should've been pre-pulled, but just in case)
51-
if (!await docker.getImage(DOCKER_TUNNEL_IMAGE).inspect().catch(() => false)) {
52-
await pullTunnelImage(docker);
53-
}
54-
5550
// Ensure we have a ready-to-use container here:
5651
const containerName = getDockerTunnelContainerName(proxyPort);
5752
let container = await docker.getContainer(containerName)
5853
.inspect().catch(() => undefined);
5954
if (!container) {
55+
// Make sure we have the image available (should've been pre-pulled, but just in case)
56+
if (!await docker.getImage(DOCKER_TUNNEL_IMAGE).inspect().catch(() => false)) {
57+
await pullTunnelImage(docker);
58+
}
59+
6060
await docker.createContainer({
6161
name: containerName,
6262
Image: DOCKER_TUNNEL_IMAGE,

0 commit comments

Comments
 (0)