docker/cli ยท error

no public port '%s' published for %s

Error message

no public port '%s' published for %s

What it means

Error "no public port '%s' published for %s" thrown in docker/cli.

Source

Thrown at cli/command/container/port.go:69

//
// TODO(thaJeztah): currently this defaults to show the TCP port if no
// proto is specified. We should consider changing this to "any" protocol
// for the given private port.
func runPort(ctx context.Context, dockerCli command.Cli, opts *portOptions) error {
	c, err := dockerCli.Client().ContainerInspect(ctx, opts.container, client.ContainerInspectOptions{})
	if err != nil {
		return err
	}

	var out []string
	if opts.port != "" {
		port, err := network.ParsePort(opts.port)
		if err != nil {
			return err
		}
		frontends, exists := c.Container.NetworkSettings.Ports[port]
		if !exists || len(frontends) == 0 {
			return fmt.Errorf("no public port '%s' published for %s", opts.port, opts.container)
		}
		for _, frontend := range frontends {
			out = append(out, net.JoinHostPort(frontend.HostIP.String(), frontend.HostPort))
		}
	} else {
		for from, frontends := range c.Container.NetworkSettings.Ports {
			for _, frontend := range frontends {
				out = append(out, fmt.Sprintf("%s -> %s", from, net.JoinHostPort(frontend.HostIP.String(), frontend.HostPort)))
			}
		}
	}

	if len(out) > 0 {
		sort.Slice(out, func(i, j int) bool {
			return sortorder.NaturalLess(out[i], out[j])
		})
		_, _ = fmt.Fprintln(dockerCli.Out(), strings.Join(out, "\n"))
	}

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/container/port.go:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/3010479d5ef2098a.json. Report an issue: GitHub.