MCPcopy Index your code
hub / github.com/docker/cli / newPortCommand

Function newPortCommand

cli/command/container/port.go:26–47  ·  view source on GitHub ↗

newPortCommand creates a new cobra.Command for "docker container port".

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

24
25// newPortCommand creates a new cobra.Command for "docker container port".
26func newPortCommand(dockerCLI command.Cli) *cobra.Command {
27 var opts portOptions
28
29 cmd := &cobra.Command{
30 Use: "port CONTAINER [PRIVATE_PORT[/PROTO]]",
31 Short: "List port mappings or a specific mapping for the container",
32 Args: cli.RequiresRangeArgs(1, 2),
33 RunE: func(cmd *cobra.Command, args []string) error {
34 opts.container = args[0]
35 if len(args) > 1 {
36 opts.port = args[1]
37 }
38 return runPort(cmd.Context(), dockerCLI, &opts)
39 },
40 Annotations: map[string]string{
41 "aliases": "docker container port, docker port",
42 },
43 ValidArgsFunction: completion.ContainerNames(dockerCLI, false),
44 DisableFlagsInUseLine: true,
45 }
46 return cmd
47}
48
49// runPort shows the port mapping for a given container. Optionally, it
50// allows showing the mapping for a specific (container)port and proto.

Callers 2

newContainerCommandFunction · 0.85
TestNewPortCommandOutputFunction · 0.85

Calls 1

runPortFunction · 0.85

Tested by 1

TestNewPortCommandOutputFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…