Skip to content

fix: pin Traefik routing to the isolated network on isolated deployments - #5004

Merged
Siumauricio merged 1 commit into
canaryfrom
fix/isolated-deployment-traefik-network-label
Aug 7, 2026
Merged

fix: pin Traefik routing to the isolated network on isolated deployments#5004
Siumauricio merged 1 commit into
canaryfrom
fix/isolated-deployment-traefik-network-label

Conversation

@Siumauricio

@Siumauricio Siumauricio commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem

When Isolated Deployment is enabled, Dokploy intentionally skips the traefik.docker.network label on domain-linked services. If the container is attached to more than one network (e.g. the isolated network plus an internal network declared in the compose file), Traefik picks the backend IP arbitrarily among the container's networks, and re-picks on every provider config rebuild (any docker event on the host).

When it picks the internal network — where Traefik is not connected — the domain becomes unreachable until the next re-roll. This exactly matches the reported behavior: one successful request after redeploy, then dead, and seemingly random interference between deployments (any deploy/restart on the host triggers a re-pick for every ambiguous service).

Verified live: with two services sharing an internal network and isolation enabled, Traefik's /api/http/services flipped between the isolated network IP (working) and the internal network IP (dead) across consecutive config rebuilds.

Fix

Emit the network hint label in isolated mode too, pointing at the isolated network (suffix || appName) — the same network dokploy-traefik is connected to during deploy:

  • traefik.docker.network=<isolated network> for docker-compose
  • traefik.swarm.network=<isolated network> for stack

After the fix, the selected backend IP stays pinned to the isolated network across rebuilds (verified over repeated provider refreshes, all requests 200).

Closes #4899
Closes #4040 (author confirmed it was an isolated deployment; manually adding the network label fixed it)

Related (same multi-network ambiguity class, not closed by this PR): #3945, #3313

Greptile Summary

Pins Traefik routing for isolated Compose deployments to the deployment's isolated network.

  • Adds traefik.docker.network for Docker Compose services.
  • Adds traefik.swarm.network for Docker Swarm stacks.
  • Derives the isolated network hint from the configured suffix or application name.

Confidence Score: 4/5

The mapping-form label path must be handled before merging because it bypasses the new isolated-network pin and leaves affected domains intermittently unreachable.

The new pinning logic only runs for array-form labels, while the supported mapping form skips all generated labels and therefore retains ambiguous Traefik network selection.

Files Needing Attention: packages/server/src/utils/docker/domain.ts

Reviews (1): Last reviewed commit: "fix: pin traefik routing to the isolated..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used:

@Siumauricio Siumauricio added the hotfix Cherry-pick this fix to main for next patch release label Aug 7, 2026
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 7, 2026
@Siumauricio
Siumauricio merged commit bcab5b0 into canary Aug 7, 2026
7 checks passed
@Siumauricio
Siumauricio deleted the fix/isolated-deployment-traefik-network-label branch August 7, 2026 07:14
Comment on lines +223 to 234
} else {
const isolatedNetwork = compose.suffix || compose.appName;
if (compose.composeType === "docker-compose") {
if (!labels.includes(`traefik.docker.network=${isolatedNetwork}`)) {
labels.unshift(`traefik.docker.network=${isolatedNetwork}`);
}
} else {
if (!labels.includes(`traefik.swarm.network=${isolatedNetwork}`)) {
labels.unshift(`traefik.swarm.network=${isolatedNetwork}`);
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Mapping labels bypass network pinning

When an isolated service uses Compose's valid mapping form for labels, the surrounding Array.isArray(labels) guard skips this new network label entirely, leaving multi-network services subject to the same ambiguous Traefik backend selection and intermittent domain outages this change is intended to fix.

Knowledge Base Used: Traefik Networking

@wagnersoares0

Copy link
Copy Markdown

Nice hotfix. One small follow-up question: does this also cover Compose labels written as a mapping instead of an array?

Greptile called out that the current change may still skip that path. If that is still open, I can try a small follow-up PR for the mapping-form case and add a regression test around isolated deployments with multiple networks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotfix Cherry-pick this fix to main for next patch release size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

2 participants