Skip to content

Commit d43e3f7

Browse files
committed
Handle races in Docker container removal/recreation
1 parent a968481 commit d43e3f7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/interceptors/docker/docker-commands.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as _ from 'lodash';
22
import * as Docker from 'dockerode';
33
import * as path from 'path';
44

5+
import { delay } from '../../util/promise';
6+
57
import { getTerminalEnvVars } from '../terminal/terminal-env-overrides';
68
import { transformComposeCreationLabels } from './docker-compose';
79
import { getDockerDataVolumeName } from './docker-data-injection';
@@ -214,6 +216,11 @@ export async function restartAndInjectContainer(
214216
}
215217
});
216218

219+
// There can be a delay here - wait until the container disappears
220+
while (await container.inspect().catch(() => false)) {
221+
await delay(100);
222+
}
223+
217224
// First we clone the continer, injecting our custom settings:
218225
const newContainer = await docker.createContainer(
219226
await transformContainerCreationConfig(

0 commit comments

Comments
 (0)