dockerclient

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dockerclient is a minimal HTTP client for the Docker Engine API.

It exists to avoid pulling in the full github.com/docker/docker module, which is flagged by SCA scanners for several CVEs that affect dockerd (server-side) and the docker CLI — not the client SDK the agent actually uses. As of 2026-05 three of those CVEs have no upstream fix at all (CVE-2026-41567, -42306, -41568), so the only way to clear them from the SBOM is to remove the module entirely.

Only the three endpoints the agent needs are implemented:

  • GET /_ping (connectivity check + API version detection)
  • GET /version (used during API version negotiation)
  • GET /containers/{id}/json (the only inspection call the agent makes)

Wire format follows the Docker Engine API as published at https://docs.docker.com/engine/api/ and matches what dockerd actually returns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(socketPath string) (*Client, error)

NewClient opens a Docker client against a unix socket path.

func (*Client) ContainerInspect

func (c *Client) ContainerInspect(ctx context.Context, id string) (*ContainerJSON, error)

ContainerInspect returns the subset of the /containers/{id}/json response that the agent reads.

func (*Client) NegotiateAPIVersion

func (c *Client) NegotiateAPIVersion(ctx context.Context)

NegotiateAPIVersion asks the daemon for its API version and pins the client to it. Silently falls back to the default if the daemon doesn't return one.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping checks that the daemon is reachable.

type Config

type Config struct {
	Image  string
	Labels map[string]string
	Env    []string
}

type ContainerJSON

type ContainerJSON struct {
	Name            string
	LogPath         string
	Config          *Config
	HostConfig      *HostConfig
	Mounts          []MountPoint
	NetworkSettings *NetworkSettings
}

ContainerJSON mirrors the fields of github.com/docker/docker/api/types.ContainerJSON that the agent reads. Anything not needed is intentionally omitted.

type EndpointSettings

type EndpointSettings struct {
	NetworkID string
}

type HostConfig

type HostConfig struct {
	LogConfig LogConfig
}

type LogConfig

type LogConfig struct {
	Type string
}

type MountPoint

type MountPoint struct {
	Source      string
	Destination string
}

type NetworkSettings

type NetworkSettings struct {
	Ports    map[Port][]PortBinding
	Networks map[string]*EndpointSettings
}

type Port

type Port string

Port is a "<port>/<protocol>" string (e.g., "80/tcp") matching docker's wire format.

func (Port) Proto

func (p Port) Proto() string

Proto returns the protocol component (after the slash).

type PortBinding

type PortBinding struct {
	HostIP   string
	HostPort string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL