slimtoolkit/slim · error

slim: error => missing comms ports

Error message

slim: error => missing comms ports

What it means

After inspecting the container, docker-slim checks that the container's reported NetworkSettings.Ports contains at least as many entries as the communication ports (commsExposedPorts, derived from the target's ExposedPorts config). If the engine reports fewer mapped ports than expected, the inspector cannot reach the app, so it fails with this error. It only applies when the container is not host-networked.

Source

Thrown at pkg/app/master/inspectors/container/container_inspector.go:755

	if err := i.APIClient.StartContainer(i.ContainerID, nil); err != nil {
		return err
	}

	inspectContainerOpts := dockerapi.InspectContainerOptions{ID: i.ContainerID, Size: true}
	if i.ContainerInfo, err = i.APIClient.InspectContainerWithOptions(inspectContainerOpts); err != nil {
		return err
	}

	if i.ContainerInfo.NetworkSettings == nil {
		return fmt.Errorf("slim: error => no network info")
	}

	if hCfg := i.ContainerInfo.HostConfig; hCfg != nil && !i.isHostNetworked() {
		logger.Debugf("container HostConfig.NetworkMode => %s len(ports)=%d",
			hCfg.NetworkMode, len(i.ContainerInfo.NetworkSettings.Ports))

		if len(i.ContainerInfo.NetworkSettings.Ports) < len(commsExposedPorts) {
			return fmt.Errorf("slim: error => missing comms ports")
		}
	}

	logger.Debugf("container NetworkSettings.Ports => %#v", i.ContainerInfo.NetworkSettings.Ports)

	i.setAvailablePorts(hostProbePorts)

	if i.PrintState {
		i.xc.Out.Info("container",
			ovars{
				"status": "running",
				"name":   containerInfo.Name,
				"id":     i.ContainerID,
			})
	}

	if err = i.initContainerChannels(); err != nil {
		return err

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Confirm the target image EXPOSEs or the slim command exposes all ports the app actually uses (e.g. --expose 8080).
  2. Check docker inspect <container> NetworkSettings.Ports to see which ports the engine reports.
  3. Avoid --network host conflicts; ensure the container runs on a normal bridge network or adjust slim flags accordingly.
  4. Publish the missing ports explicitly (docker run -p 8080:8080) if the app needs inbound access.

Example fix

// before: image lacks exposed ports
FROM golang
CMD ["/app"]
// after
FROM golang
EXPOSE 8080
CMD ["/app"]
// or run slim with: slim build --expose 8080 -- <image>
Defensive patterns

Strategy: validation

Validate before calling

info, _ := client.InspectContainerWithOptions(opts)
if info.NetworkSettings != nil && len(info.NetworkSettings.Ports) < len(expectedExposedPorts) {
    // fix EXPOSE/-p flags before running slim
    fmt.Println("container reports fewer ports than expected")
}

Type guard

func hasAllCommsPorts(info *dockertypes.ContainerJSON, want int) bool {
    return info != nil && info.NetworkSettings != nil && len(info.NetworkSettings.Ports) >= want
}

Try / catch

if err := runSlim(); err != nil && strings.Contains(err.Error(), "missing comms ports") {
    log.Fatal("add --expose <port> for every port your app listens on, then re-run slim")
}

Prevention

When it happens

Trigger: RunContainer on a non-host-networked container where len(NetworkSettings.Ports) < len(commsExposedPorts) — i.e. some of the ports declared via --expose/EXPOSE or slim's --http-probe flags were not actually published or reported by the engine.

Common situations: Using --network host assumptions with a bridge container; image EXPOSE metadata mismatching actual listening ports; docker run overriding port publishing; Docker versions reporting ports differently.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/0c92648e2f566a80. Report an issue: GitHub.