fix(docker): handle container name conflict automatically

When a Docker container with the same name already exists (e.g., from a
   previous crashed GNS3 session), Docker returns a 409 Conflict error
   when trying to create a new container with that name. This causes the
   project open operation to fail.

   This fix adds automatic cleanup of stale containers when encountering
   a name conflict:
   - Added DockerHttp409Error exception class
   - Updated http_query to detect 409 status codes
   - Modified create() to remove conflicting containers and retry

   Fixes the issue where opening a project fails with:
   "Docker has returned an error: 409 Conflict. The container name
   '/GNS3.xxx' is already in use by container 'xxx'"
This commit is contained in:
YueGuobin committed 2026-02-27 23:35:11 +08:00
1 parent a0116902a6
commit ce90b2b92c
3 files changed
+30 -3

No files matched your search

@@ -31,3 +31,7 @@ class DockerHttp304Error(DockerError):
class DockerHttp404Error(DockerError):
pass
class DockerHttp409Error(DockerError):
pass