MCPcopy
hub / github.com/docker/compose / connectNetwork

Method connectNetwork

pkg/compose/create.go:1527–1544  ·  pkg/compose/create.go::composeService.connectNetwork
(
	ctx context.Context,
	nwName string,
	containers Containers,
	config *network.EndpointSettings,
)

Source from the content-addressed store, hash-verified

1525}
1526
1527func (s *composeService) connectNetwork(
1528 ctx context.Context,
1529 nwName string,
1530 containers Containers,
1531 config *network.EndpointSettings,
1532) error {
1533 for _, c := range containers {
1534 _, err := s.apiClient().NetworkConnect(ctx, nwName, client.NetworkConnectOptions{
1535 Container: c.ID,
1536 EndpointConfig: config,
1537 })
1538 if err != nil {
1539 return err
1540 }
1541 }
1542
1543 return nil
1544}
1545
1546func (s *composeService) resolveExternalNetwork(ctx context.Context, n *types.NetworkConfig) (string, error) {
1547 // NetworkInspect will match on ID prefix, so NetworkList with a name

Callers 1

Calls 2

apiClientMethod · 0.95
NetworkConnectMethod · 0.45

Tested by

no test coverage detected