mocker icon indicating copy to clipboard operation
mocker copied to clipboard

A compose service can only join one network

Open us opened this issue 3 months ago • 2 comments

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.

us avatar Aug 09 '26 19:08 us

container 1.5.0 now boots a container on several networks, so compose services join every network they list. Verified with web [front], api [front, back], db [back]: api reaches both, web cannot reach db, and service names resolve only across shared networks. Shipped in #98.

mocker network connect / disconnect still depend on the runtime adding a way to attach a running container.

us avatar Oct 19 '26 16:10 us

Released in v0.9.5 (brew upgrade mocker). Closing.

us avatar Oct 19 '26 17:10 us