cli

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package cli provides the Doki command-line interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateFlags added in v0.10.0

func ValidateFlags(args []string, validFlags []string, valueFlags []string) error

ValidateFlags returns an error if args contains any token starting with "-" that is not listed in validFlags. Flags in valueFlags consume the next token as their value, and that token is not inspected. The first unknown flag triggers the returned error, formatted as "invalid flag: <flag>".

Types

type DokiCLI

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

DokiCLI is the Doki command-line client that communicates with the Doki daemon via Unix socket.

func New

func New(socket string) *DokiCLI

New creates a new DokiCLI client connected to the given Unix socket.

func (*DokiCLI) Apply

func (c *DokiCLI) Apply(file string) error

Apply applies a YAML/JSON configuration to create or update resources.

func (*DokiCLI) Attach

func (c *DokiCLI) Attach(containerID string, _ string, _ string) error

Attach attaches to a running container.

func (*DokiCLI) AutoUpdate

func (c *DokiCLI) AutoUpdate() error

AutoUpdate checks for and applies image updates to containers.

func (*DokiCLI) Build

func (c *DokiCLI) Build(contextDir, dokifile string, tags []string, buildArgs map[string]string, noCache, pull, quiet, rm bool, target string) error

Build builds an image from a Dockerfile.

func (*DokiCLI) Commit

func (c *DokiCLI) Commit(_, repo, tag, author, _ string, pause bool, _ []string) error

Commit creates a new image from a container's changes.

func (*DokiCLI) Cp

func (c *DokiCLI) Cp(containerID, srcPath, destPath string, _, _ bool) error

Cp copies files from a container to the local filesystem.

func (*DokiCLI) CpToContainer

func (c *DokiCLI) CpToContainer(containerID, srcPath, destPath string, _ bool, _ bool) error

CpToContainer copies files from the local filesystem into a container.

func (*DokiCLI) Create

func (c *DokiCLI) Create(image string, cmd []string, opts *RunFlags) (string, error)

Create registers a new container from the given image without starting it.

func (*DokiCLI) Diff

func (c *DokiCLI) Diff(containerID string) error

Diff shows changes to files and directories in a container.

func (*DokiCLI) Events

func (c *DokiCLI) Events(filter string) error

Events streams real-time events from the daemon with an optional filter.

func (*DokiCLI) Exec

func (c *DokiCLI) Exec(containerID string, cmd []string, tty, detach, interactive bool, env []string, workdir, user string) error

Exec runs a command inside an existing container.

func (*DokiCLI) Export

func (c *DokiCLI) Export(containerID string, output string) error

Export exports a container filesystem as a tar archive.

func (*DokiCLI) GenerateKube

func (c *DokiCLI) GenerateKube(containerID string, _ bool) error

GenerateKube generates Kubernetes YAML from containers or pods.

func (*DokiCLI) Healthcheck

func (c *DokiCLI) Healthcheck(containerID string) error

Healthcheck shows the health status of a container.

func (*DokiCLI) History

func (c *DokiCLI) History(imageName string, noTrunc, _ bool) error

History shows the history of an image.

func (*DokiCLI) Images

func (c *DokiCLI) Images(all, quiet, noTrunc bool, filter string) error

Images lists available images.

func (*DokiCLI) ImagesPrune

func (c *DokiCLI) ImagesPrune(_ bool, _ string) error

ImagesPrune removes unused images.

func (*DokiCLI) Import

func (c *DokiCLI) Import(source, repo, tag string, _ []string, _ string) error

Import creates an image from a tarball or URL.

func (*DokiCLI) Inspect

func (c *DokiCLI) Inspect(containerIDs []string, format string) error

Inspect returns detailed information about containers or images in JSON format.

func (*DokiCLI) Kill

func (c *DokiCLI) Kill(ids []string, signal string) error

Kill sends a signal to one or more containers.

func (*DokiCLI) KubeDown

func (c *DokiCLI) KubeDown(file string) error

KubeDown tears down resources described in a Kubernetes YAML file.

func (*DokiCLI) KubeGenerate

func (c *DokiCLI) KubeGenerate(what string) error

KubeGenerate generates Kubernetes YAML for a given resource type.

func (*DokiCLI) KubePlay

func (c *DokiCLI) KubePlay(file string) error

KubePlay creates containers from a Kubernetes YAML file.

func (*DokiCLI) LinkAdd added in v0.9.3

func (c *DokiCLI) LinkAdd(id, addr, pubB64 string) error

LinkAdd adds a static peer to the mesh.

func (*DokiCLI) LinkRemove added in v0.9.3

func (c *DokiCLI) LinkRemove(id string) error

LinkRemove removes a peer from the static list.

func (*DokiCLI) LinkShow added in v0.9.3

func (c *DokiCLI) LinkShow() error

LinkShow prints the raw peers.json for debugging.

func (*DokiCLI) Load

func (c *DokiCLI) Load(input string, quiet bool) error

Load imports an image from a tar archive.

func (*DokiCLI) Login

func (c *DokiCLI) Login(server, username, password string) error

Login authenticates to a container registry.

func (*DokiCLI) Logout

func (c *DokiCLI) Logout(_ string) error

Logout removes registry authentication credentials.

func (*DokiCLI) Logs

func (c *DokiCLI) Logs(containerID string, follow, timestamps bool, tail int, _ string) error

Logs fetches and displays the logs of a container.

func (*DokiCLI) MeshLs added in v0.9.3

func (c *DokiCLI) MeshLs() error

MeshLs lists the peers known to this Doki instance.

func (*DokiCLI) MeshStatus added in v0.9.3

func (c *DokiCLI) MeshStatus() error

MeshStatus returns the local mesh install id and CA fingerprint.

func (*DokiCLI) Mount

func (c *DokiCLI) Mount(_ []string) error

Mount mounts a container filesystem.

func (*DokiCLI) NetworkConnect

func (c *DokiCLI) NetworkConnect(networkID, containerID string, aliases []string) error

NetworkConnect connects a container to a network.

func (*DokiCLI) NetworkCreate

func (c *DokiCLI) NetworkCreate(name, driver string, internal, ipv6 bool, subnet, gateway string, _ map[string]string) error

NetworkCreate creates a new network.

func (*DokiCLI) NetworkDisconnect

func (c *DokiCLI) NetworkDisconnect(networkID, containerID string, force bool) error

NetworkDisconnect disconnects a container from a network.

func (*DokiCLI) NetworkInspect

func (c *DokiCLI) NetworkInspect(ids []string) error

NetworkInspect shows detailed information about networks.

func (*DokiCLI) NetworkLs

func (c *DokiCLI) NetworkLs(_ bool, _ bool, _ string, _ string) error

NetworkLs lists networks.

func (*DokiCLI) NetworkPrune

func (c *DokiCLI) NetworkPrune(_ string) error

NetworkPrune removes all unused networks.

func (*DokiCLI) NetworkRm

func (c *DokiCLI) NetworkRm(ids []string) error

NetworkRm removes one or more networks.

func (*DokiCLI) Pause

func (c *DokiCLI) Pause(ids []string) error

Pause suspends one or more running containers.

func (*DokiCLI) Ping

func (c *DokiCLI) Ping() error

Ping checks whether the Doki daemon is reachable.

func (*DokiCLI) PodCreate

func (c *DokiCLI) PodCreate(name string, labels map[string]string) (string, error)

PodCreate creates a new pod.

func (*DokiCLI) PodPs

func (c *DokiCLI) PodPs() error

PodPs lists pods.

func (*DokiCLI) PodRm

func (c *DokiCLI) PodRm(ids []string, force bool) error

PodRm removes one or more pods.

func (*DokiCLI) PodStart

func (c *DokiCLI) PodStart(ids []string) error

PodStart starts one or more pods.

func (*DokiCLI) PodStop

func (c *DokiCLI) PodStop(ids []string) error

PodStop stops one or more pods.

func (*DokiCLI) Port

func (c *DokiCLI) Port(containerID, privatePort string) error

Port displays the public-facing port for a container.

func (*DokiCLI) Prune

func (c *DokiCLI) Prune(_ bool, _ string) error

Prune removes all stopped containers.

func (*DokiCLI) Ps

func (c *DokiCLI) Ps(all, quiet, noTrunc bool, filter, format string, _ int, _ bool) error

Ps lists running containers in a table or JSON format.

func (*DokiCLI) Pull

func (c *DokiCLI) Pull(imageName string, _ bool, quiet bool) error

Pull downloads an image from a registry.

func (*DokiCLI) Push

func (c *DokiCLI) Push(imageName string, allTags, quiet bool) error

Push uploads an image to a registry.

func (*DokiCLI) Rename

func (c *DokiCLI) Rename(containerID, newName string) error

Rename renames a container.

func (*DokiCLI) Restart

func (c *DokiCLI) Restart(ids []string, timeout int) error

Restart restarts one or more containers.

func (*DokiCLI) Rm

func (c *DokiCLI) Rm(ids []string, force, volumes, _ bool) error

Rm removes one or more containers.

func (*DokiCLI) Rmi

func (c *DokiCLI) Rmi(ids []string, force, _ bool) error

Rmi removes one or more images.

func (*DokiCLI) Run

func (c *DokiCLI) Run(args []string) error

Run creates and starts a new container from an image with the given arguments and flags.

func (*DokiCLI) Save

func (c *DokiCLI) Save(imageNames []string, output string) error

Save exports one or more images to a tar archive.

func (*DokiCLI) Scout

func (c *DokiCLI) Scout(_ string) error

Scout scans an image for vulnerabilities.

func (*DokiCLI) Search

func (c *DokiCLI) Search(term string, limit int, _ bool, _ int) error

Search searches the Docker Hub for images.

func (*DokiCLI) Start

func (c *DokiCLI) Start(ids []string) error

Start starts one or more stopped containers.

func (*DokiCLI) Stats

func (c *DokiCLI) Stats(containerIDs []string, noStream bool) error

Stats displays resource usage statistics for one or more containers.

func (*DokiCLI) Stop

func (c *DokiCLI) Stop(ids []string, timeout int) error

Stop stops one or more running containers.

func (*DokiCLI) SystemDf

func (c *DokiCLI) SystemDf(verbose bool) error

SystemDf shows disk usage by images, containers, and volumes.

func (*DokiCLI) SystemDialStdio

func (c *DokiCLI) SystemDialStdio() error

SystemDialStdio connects stdin/stdout to the daemon.

func (*DokiCLI) SystemEvents

func (c *DokiCLI) SystemEvents(_ string, _ string, _ string) error

SystemEvents streams real-time events from the daemon.

func (*DokiCLI) SystemInfo

func (c *DokiCLI) SystemInfo() error

SystemInfo displays system-wide information.

func (*DokiCLI) SystemPrune

func (c *DokiCLI) SystemPrune(all, volumes bool, _ string) error

SystemPrune removes unused containers, images, and optionally volumes.

func (*DokiCLI) SystemVersion

func (c *DokiCLI) SystemVersion() error

SystemVersion shows the Doki version information.

func (*DokiCLI) Tag

func (c *DokiCLI) Tag(source, target string) error

Tag assigns a new tag to an image.

func (*DokiCLI) Top

func (c *DokiCLI) Top(containerID string, psArgs string) error

Top displays the running processes of a container.

func (*DokiCLI) Unmount

func (c *DokiCLI) Unmount(_ []string) error

Unmount unmounts a container filesystem.

func (*DokiCLI) Unpause

func (c *DokiCLI) Unpause(ids []string) error

Unpause resumes one or more paused containers.

func (*DokiCLI) Unshare

func (c *DokiCLI) Unshare(_ []string) error

Unshare runs a command in a new user namespace.

func (*DokiCLI) Untag

func (c *DokiCLI) Untag(_ string) error

Untag removes a tag from an image.

func (*DokiCLI) Update

func (c *DokiCLI) Update(containerID string, flags *RunFlags) error

Update modifies the resource configuration of a container.

func (*DokiCLI) VerifyImageSignature

func (c *DokiCLI) VerifyImageSignature(imageName string) error

VerifyImageSignature checks if an image has a valid signature.

func (*DokiCLI) VolumeCreate

func (c *DokiCLI) VolumeCreate(name, driver string, opts, labels map[string]string) error

VolumeCreate creates a new volume.

func (*DokiCLI) VolumeInspect

func (c *DokiCLI) VolumeInspect(ids []string) error

VolumeInspect shows detailed information about volumes.

func (*DokiCLI) VolumeLs

func (c *DokiCLI) VolumeLs(_ bool, _ string) error

VolumeLs lists volumes.

func (*DokiCLI) VolumePrune

func (c *DokiCLI) VolumePrune(_ string) error

VolumePrune removes all unused volumes.

func (*DokiCLI) VolumeRm

func (c *DokiCLI) VolumeRm(ids []string, _ bool) error

VolumeRm removes one or more volumes.

func (*DokiCLI) Wait

func (c *DokiCLI) Wait(containerID string) (int, error)

Wait blocks until a container stops and returns its exit code.

type ExitError added in v0.10.0

type ExitError struct {
	Code int
}

ExitError signals that the invoked process (typically a container) terminated with the given exit code. Callers (cmd/doki/main.go) detect this type via errors.As and propagate the code to os.Exit, so library code in pkg/ never calls os.Exit directly.

func (*ExitError) Error added in v0.10.0

func (e *ExitError) Error() string

type MountOpt

type MountOpt struct {
	Type        string
	Source      string
	Target      string
	ReadOnly    bool
	Consistency string
}

MountOpt represents a single --mount flag value.

type RunFlags

type RunFlags struct {
	Name              string
	Detach            bool
	Interactive       bool
	TTY               bool
	RM                bool
	Privileged        bool
	ReadOnly          bool
	Network           string
	RestartPolicy     string
	CPUShares         int64
	Memory            int64
	MemorySwap        int64
	NanoCPUs          int64
	CPUSetCPUs        string
	CPUSetMems        string
	CPUPeriod         int64
	CPUQuota          int64
	PidsLimit         int64
	OOMKillDisable    bool
	ShmSize           int64
	DNS               []string
	DNSSearch         []string
	DNSOptions        []string
	ExtraHosts        []string
	Env               []string
	EnvFile           []string
	Workdir           string
	User              string
	Entrypoint        string
	StopSignal        string
	StopTimeout       int
	Init              bool
	Pull              string
	Platform          string
	CapAdd            []string
	CapDrop           []string
	SecurityOpt       []string
	Sysctls           map[string]string
	Ulimits           []string
	LogDriver         string
	LogOpts           map[string]string
	Ports             []string
	PublishAll        bool
	Volumes           []string
	Mounts            []MountOpt
	Devices           []string
	DeviceCgroupRules []string
	GroupAdd          []string
	Hostname          string
	Domainname        string
	IP                string
	IP6               string
	Link              []string
	LinkLocalIP       string
	MACAddress        string
	BlkioWeight       uint16
	CgroupParent      string
	CgroupNS          string
	IPCMode           string
	PIDMode           string
	UTSMode           string
	UsernsMode        string
	Isolation         string
	Runtime_RT        string
	StorageOpt        map[string]string
	VolumeDriver      string
	VolumesFrom       []string
	Expose            []string
	Labels            map[string]string
	LabelFile         []string
	Annotations       map[string]string
	HealthCmd         string
	HealthInterval    string
	HealthTimeout     string
	HealthRetries     int
	HealthStartPeriod string
	GPUs              string
}

RunFlags holds all the flags accepted by the run command.

func ParseRunFlags

func ParseRunFlags(args []string) (image string, cmd []string, flags *RunFlags)

ParseRunFlags parses command-line arguments for the run command.

Jump to

Keyboard shortcuts

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