Manually attaching services to dokploy-network silently causes cross-project DNS collisions (service short name round-robins across stacks)

Aperta
#6,028 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
docker, docker-compose, typescript

Direzione di ricerca

Start by tracing where Compose stacks are processed during deployment, as the issue does not name specific files or entry points. Compare the proposed deploy warning and documentation note to determine which change is in scope, then inspect how services attach to dokploy-network. Done means preventing or clearly documenting cross-project short-name DNS collisions; the issue offers no named test to run.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Summary

When a Compose stack attaches its services to the shared dokploy-network (declaring it external: true and listing it under a service's networks:, as many community templates and examples do), Docker Compose registers each service under its bare short name as a network-scoped alias on that shared overlay. Every project does the same, so a lookup of a common name like api, web, worker, redis or postgres resolves round-robin across every stack's container with that name. A server-side call such as fetch('http://api:8000/...') then reaches a different project's container at random: connection refused, a 404 from an unrelated app, or (worse) a silent success against the wrong database.

This is the same class of problem as #1004 (closed via Isolated Deployments), but it still bites anyone who attaches dokploy-network manually, which is common and shown in many examples. The failure is intermittent and very hard to diagnose, because most requests happen to hit the right container.

Minimal reproduction

Two separate Compose apps, each:

services:
  api:
    image: hashicorp/http-echo
    command: ["-text=STACK-A"]   # STACK-B in the other app
    networks: [default, dokploy-network]
networks:
  dokploy-network:
    external: true

Deploy both. From any container on dokploy-network:

for i in $(seq 10); do getent hosts api; done   # returns BOTH stacks' IPs, round-robin

A consumer hard-coded to http://api:<port> gets whichever stack answers that lookup, non-deterministically.

Root cause

Docker Compose always adds the service name as a network-scoped alias on every network the service joins, including an external shared one. On a single flat overlay shared by all projects, those aliases collide, and Docker's embedded DNS returns all matching A records and round-robins between them. (Background: Docker Forums, "Networking Two Compose Stacks - Round Robin Behaviour".)

Impact
  • Intermittent, non-deterministic failures that look like application bugs. I traced an app that randomly rendered an empty page to this; roughly 1 request in N hit a stranger's container.
  • A soft isolation concern: one stack can reach another stack's internal-only service (for example its database) by using a common service name.
Suggested fixes (any subset)
  1. Warn at deploy time when a stack attaches services to dokploy-network and a service short name already exists on that network from another project, e.g. a single log line: service name `api` also exists on dokploy-network from project X; use Isolated Deployments or a unique alias. That alone would save people hours.
  2. Document the footgun on the Compose utilities / networking pages: if you attach dokploy-network manually, inter-service URLs must use a globally unique name, not the bare service name. Minimal pattern:
    services:
      api:
        networks:
          default:
            aliases: [myproject-api]
          dokploy-network:
            aliases: [myproject-api]
    # consumer uses http://myproject-api:8000
    
  3. Keep the bare name off the shared network entirely. When Dokploy attaches dokploy-network, consider connecting it outside the Compose service networks: list, via docker network connect --alias <project>-<service> <container> dokploy-network. docker network connect does not add the Compose service name as an alias, so the collision never forms, while Traefik (which routes by container IP) is unaffected.
  4. Consider making Isolated Deployments the default for new Compose apps.
Environment
  • Dokploy, self-hosted. Multiple Compose stacks sharing dokploy-network on one host.

Happy to send a PR for the docs note (fix 2) and/or the duplicate-alias deploy warning (fix 1) if you can point me at where Compose processing happens in the deploy path.

Lingua principale
TypeScript
Stelle
38.8k
Fork
3.2k
Merge medio
1g 10h
PR unite (30g)
110

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Dokploy/dokploy

Tutte le issue di Dokploy/dokploy

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.