Task: Fix network routing of child projects via Traefik

Fix network routing of child projects via Traefik

Automate the connection of launched projects to the shared Traefik network without manual Docker operations.

Context

The pilot of an arbitrary project confirmed the Narasim → external DinD → internal Docker Compose → application scheme. Currently, buildAndRunProject does not automatically connect the external container to the Traefik network. When both bridge and docker_default were present simultaneously, Traefik selected the wrong IP; a working launch required manually connecting docker_default, disconnecting bridge, and restarting the container.

What to work on

  • Make the Traefik network part of the standard project startup.
  • Eliminate ambiguous IP selection when multiple Docker networks are present.
  • Define the minimum routing contract: domain/host, internal HTTP port, unique router/service names, entrypoint/TLS.
  • Do not require publishing a separate host port for each project.
  • Test running multiple child projects simultaneously.
  • Verify that the solution works identically locally and on the target server.

Acceptance Criteria

A new Docker Compose project is launched via the API, automatically becomes accessible via Traefik at the assigned host/domain, and requires no manual docker network connect/disconnect or individual host ports.

Ворклоги

2026-09-27 — Traffic proxying in DinD via Traefik

Routing to a child project run via Docker Compose inside DinD has been tested and brought to a working state.

Result

Working chain: external Traefik → DinD:2015 → socat → internal Traefik:80 → app:3000. The nextjs-test project is successfully accessible at http://nextjs-test.localhost:2015/.

socat and bash have been added to the child project's Dockerfile, and the external Traefik is configured to use port 2015 of the DinD container. After Compose starts, socat forwards this port to the internal Traefik.

Docker Network Management

Initially, connecting DinD to docker_default was added directly to buildAndRunProject, but it was decided not to leave this hardcoded. The network should be managed explicitly via the API.

Added:

  • DockerContainerNetwork type (name, networkID, ipAddress, gateway, macAddress);
  • lazy field DockerContainer.networks;
  • helper mapContainerNetworks;
  • query containerNetworks;
  • mutation connectContainerToNetwork;
  • mutation disconnectContainerFromNetwork.

Now a container can be programmatically connected to the external Traefik network and disconnected from it without using the Docker CLI.

Identified Nuance

If a container is connected to a network after the route has already been established, the external Traefik may continue using the old endpoint. In the conducted test, a Traefik restart was required. This should be taken into account for the future lifecycle of project startup and routing.