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

Function runPort

cmd/compose/port.go:66–86  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts portOptions, service string)

Source from the content-addressed store, hash-verified

64}
65
66func runPort(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts portOptions, service string) error {
67 projectName, err := opts.toProjectName(ctx, dockerCli)
68 if err != nil {
69 return err
70 }
71
72 backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...)
73 if err != nil {
74 return err
75 }
76 ip, port, err := backend.Port(ctx, projectName, service, opts.port, api.PortOptions{
77 Protocol: opts.protocol,
78 Index: opts.index,
79 })
80 if err != nil {
81 return err
82 }
83
84 _, _ = fmt.Fprintf(dockerCli.Out(), "%s:%d\n", ip, port)
85 return nil
86}

Callers 1

portCommandFunction · 0.85

Calls 4

NewComposeServiceFunction · 0.92
toProjectNameMethod · 0.80
PortMethod · 0.65
OutMethod · 0.45

Tested by

no test coverage detected