addContainer method
Adds a container that already exists, as if a previous run left it.
network is the Docker network name (the same string passed to
addNetwork's name), for a caller that wants removeContainer to
free that network's active endpoint again, the way Docker would.
Implementation
String addContainer({
required Map<String, String> labels,
String image = 'scratch:latest',
String state = 'running',
DateTime? created,
Map<int, int> hostPorts = const {},
List<HealthStatus> health = const [],
String logs = '',
String? network,
}) {
final id = 'fake${_nextId++}';
_containers[id] = _FakeContainer(
id: id,
image: image,
running: state == 'running',
state: state,
labels: Map.of(labels),
created: created ?? DateTime.utc(2026, 1, 1),
hostPorts: Map.of(hostPorts),
health: [...health],
logs: logs,
network: network,
);
return id;
}