Repository navigation
fix(docker): prevent scheduled Docker cleanup from pruning stopped Traefik container and image (#5698) - #5699
Conversation
| console.log("dokploy-traefik was stopped prior to cleanup; restarting it..."); | ||
| await container.start(); | ||
| } | ||
| } catch {} |
There was a problem hiding this comment.
If container.start() fails because a required mount is missing or a port is occupied, the empty catch lets cleanup continue. Existing containers lack the new label, and createTraefikInstance still creates remote containers without it. Container pruning can therefore delete the stopped dokploy-traefik, followed by its now-unused image.
Protect existing and remotely created containers too, and do not continue destructive cleanup when restarting an unprotected Traefik fails.
Knowledge Base Used: Docker networking and Traefik
| const dockerInstance = await getRemoteDocker(serverId); | ||
| const container = dockerInstance.getContainer("dokploy-traefik"); | ||
| const data = await container.inspect(); | ||
| if (!data.State.Running) { | ||
| console.log("dokploy-traefik was stopped prior to cleanup; restarting it..."); | ||
| await container.start(); |
There was a problem hiding this comment.
Cleanup starts the wrong proxy
When a remote server loses its SSH key, getRemoteDocker(serverId) returns the local Docker client. The new guard can then restart local dokploy-traefik, while execAsyncRemote rejects the remote cleanup. Deleting an SSH key reaches this state because it sets the server's sshKeyId to null.
Reject a remote cleanup without a usable key before inspecting or starting any container.
Knowledge Base Used: Infrastructure runtime
…date remote Docker connections
|
Addressed both P1 architectural review items:
|
Fixes #5698
Summary
Prevents scheduled Docker cleanup from unintentionally pruning the stopped Traefik container and image. Adds validation guards to abort cleanup if Traefik restart fails and prevents fallback to local Docker when remote Docker initialization fails.
Changes
packages/server/src/utils/docker/utils.tsto inspect and verify Traefik status before cleanupgetRemoteDockerthrows an explicit error instead of falling back to local Docker when remote server initialization failsTesting
pnpm test— all tests pass.