Park source container on duplicate so host ports can be reused
Release rolling / release (push) Has been cancelled

When duplicating with the same host ports, stop+rename the origin, deploy
and verify the new container, then remove the parked source. Client
precheck ignores ports owned only by the origin to avoid false blocks.
This commit is contained in:
Raven Scott
2026-07-16 22:24:49 -04:00
parent ca3770da59
commit bd512df950
7 changed files with 520 additions and 28 deletions
+18 -1
View File
@@ -108,19 +108,36 @@ export async function suggestNetworkIPAM(opts = {}) {
/**
* Host ports published by containers.
* Includes per-port owners so clients can ignore the source container when
* duplicating (swap) without false host-port conflicts.
*/
export async function listUsedHostPorts() {
const containers = await docker.listContainers({ all: true })
/** @type {Set<number>} */
const ports = new Set()
/** @type {{ port: number, protocol: string, id: string, name: string }[]} */
const owners = []
for (const c of containers) {
const id = String(c.Id || '')
const name = String(c.Names?.[0] || '')
.replace(/^\//, '') || id.slice(0, 12)
for (const p of c.Ports || []) {
if (p.PublicPort) ports.add(Number(p.PublicPort))
if (!p?.PublicPort) continue
const port = Number(p.PublicPort)
if (!Number.isFinite(port)) continue
ports.add(port)
owners.push({
port,
protocol: String(p.Type || 'tcp').toLowerCase() === 'udp' ? 'udp' : 'tcp',
id,
name,
})
}
}
return {
success: true,
ports: [...ports].sort((a, b) => a - b),
owners,
}
}