Skip to content

A compose service can only join one network #82

Description

@us

Compose lets a service list several networks:

services:
  api:
    networks: [frontend, backend]

mocker joins the first and warns on stderr which one it picked. The limit is the runtime, not the parsing: attaching a container to two networks fails inside the guest.

$ container run --network neta --network netb -d --name multinet alpine:3.20 sleep 15
Error: failed to bootstrap container (cause: "internalError: "failed to bootstrap container multinet (cause: \"unknown: \"internalError: \"ipRouteAddDefault\"\"\")"")

So a project that relies on network segmentation (a service reachable from one network but not another) cannot be reproduced faithfully — everything the first network can reach, it reaches.

Two things would need to change: ContainerConfig.network becoming a list and the runtime accepting more than one attachment. The second is the blocker, and container network has no connect subcommand to add one after the fact either — which is also why mocker network connect/disconnect report that they are unsupported.

Tracking this so the limitation is visible rather than surprising. Ref #80.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions