Add Portainer-style container name replace on deploy.
Release rolling / release (push) Has been cancelled
Release rolling / release (push) Has been cancelled
When deploying a container whose name already exists, prompt to Replace (stop and remove the old container) or Cancel. Server accepts replace:true to perform the swap; clients pre-check names and retry on conflict races.
This commit is contained in:
+17
-3
@@ -24,6 +24,12 @@ const CODE_MAP = {
|
||||
'A name or port is already in use. Rename the container, change the host port, or remove the existing resource.',
|
||||
severity: 'warning',
|
||||
},
|
||||
CONTAINER_NAME_CONFLICT: {
|
||||
title: 'Container name already in use',
|
||||
recovery:
|
||||
'Choose Replace to stop and remove the existing container, then deploy with your new settings — or pick a different name.',
|
||||
severity: 'warning',
|
||||
},
|
||||
DOCKER_ERROR: {
|
||||
title: 'Docker engine error',
|
||||
recovery: 'Read the error detail below, fix the configuration, and retry deploy.',
|
||||
@@ -243,12 +249,20 @@ function classifyDockerMessage(message, method) {
|
||||
severity: 'warning',
|
||||
}
|
||||
}
|
||||
if (/container name|already in use by container|name .* already/i.test(lower) && /use|conflict|taken/i.test(lower)) {
|
||||
if (
|
||||
err?.code === 'CONTAINER_NAME_CONFLICT' ||
|
||||
(/container name|already in use by container|name .* already|already exists/i.test(lower) &&
|
||||
/use|conflict|taken|exists|replace/i.test(lower))
|
||||
) {
|
||||
return {
|
||||
code: 'DOCKER_CONFLICT',
|
||||
code:
|
||||
err?.code === 'CONTAINER_NAME_CONFLICT'
|
||||
? 'CONTAINER_NAME_CONFLICT'
|
||||
: 'DOCKER_CONFLICT',
|
||||
title: 'Container name already taken',
|
||||
message: m,
|
||||
recovery: 'Choose a different name, or remove/rename the existing container first.',
|
||||
recovery:
|
||||
'Choose Replace when prompted to stop and remove the existing container, or pick a different name.',
|
||||
severity: 'warning',
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user