Skip to content

Commit 6bf8284

Browse files
committed
Fix #33102: do not release Docker port if no containers
1 parent 5ffbef8 commit 6bf8284

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/eu/openanalytics/containerproxy/backend/docker/DockerEngineBackend.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ protected URI calculateTarget(Container container, PortMappings.PortMappingEntry
221221

222222
@Override
223223
protected void doStopProxy(Proxy proxy) throws Exception {
224+
if (proxy.getContainers().isEmpty()) {
225+
// containers not yet created, do no perform cleanup, see #33102
226+
return;
227+
}
224228
for (Container container : proxy.getContainers()) {
225229
if (container.getId() == null) {
226230
continue;
@@ -238,13 +242,15 @@ protected void doStopProxy(Proxy proxy) throws Exception {
238242
}
239243
}
240244
dockerClient.removeContainer(container.getId(), DockerClient.RemoveContainerParam.forceKill());
245+
releasePort(proxy.getId());
241246
} catch (ContainerNotFoundException e) {
247+
releasePort(proxy.getId());
242248
// ignore, container is already removed
243249
} catch (ConflictException e) {
244250
// ignore, container is currently being removed
251+
// do not release port now
245252
}
246253
}
247-
releasePort(proxy.getId());
248254
}
249255

250256
@Override

0 commit comments

Comments
 (0)