docker

package
v2.23.6 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Overview

Package docker contains the functions necessary to start or discover a Telepresence daemon running in a docker container.

Index

Constants

View Source
const (
	TpCache        = "/root/.cache/telepresence"
	DockerTpConfig = "/root/.config/telepresence"
	DockerTpLog    = "/root/.cache/telepresence/logs"
)
View Source
const Exe = "docker"

Variables

View Source
var ClientImageName = telepresenceImage //nolint:gochecknoglobals // extension point

Functions

func BuildImage

func BuildImage(ctx context.Context, context string, buildArgs []string) (string, error)

BuildImage builds an image from source. Stdout is silenced during those operations. The image ID is returned.

func ClientImage

func ClientImage(ctx context.Context) string

ClientImage returns the fully qualified name of the docker image that corresponds to the version of the current executable.

func ConnectDaemon

func ConnectDaemon(ctx context.Context, address netip.AddrPort) (conn *grpc.ClientConn, err error)

ConnectDaemon connects to a containerized daemon at the given address.

func CreateVolumes added in v2.23.0

func CreateVolumes(
	ctx context.Context,
	hostPort netip.AddrPort,
	remoteContainer string,
	mounts types.MountPolicies,
	ro bool,
) (map[string]string, error)

CreateVolumes creates the volumes necessary when mounting volumes required by when engaging the remote container. The hostPort is the <daemon ip>/<sftp port> where the access to the remote sftp-server is provided. The mounts are provided as a map of mount policies keyed by paths. Each volume is given the name of the remote container suffixed by a dash and a sequence number, starting at 0. Returns a map of paths keyed by volume names.

func DaemonArgs

func DaemonArgs(ctx context.Context, daemonID *daemon.Identifier) []string

DaemonArgs returns the arguments to pass to a docker run when starting a container daemon.

func DaemonOptions

func DaemonOptions(ctx context.Context, daemonID *daemon.Identifier, hostAddr netip.AddrPort) (opts []string, err error)

DaemonOptions returns the options necessary to pass to a docker run when starting a daemon container.

func EnableClient added in v2.13.3

func EnableClient(ctx context.Context) context.Context

func EnsureNetworkPlugin added in v2.23.0

func EnsureNetworkPlugin(ctx context.Context) (string, error)

EnsureNetworkPlugin checks if the telemount plugin is installed and installs it if that is not the case. The plugin is also enabled.

func EnsureVolumePlugin added in v2.13.0

func EnsureVolumePlugin(ctx context.Context) (string, error)

EnsureVolumePlugin checks if the telemount plugin is installed and installs it if that is not the case. The plugin is also enabled.

func GetClient added in v2.13.3

func GetClient(ctx context.Context) (*client.Client, error)

func GetDaemonContainerNetworkInfo added in v2.23.3

func GetDaemonContainerNetworkInfo(ctx context.Context) (dns netip.Addr, networkName string, err error)

GetDaemonContainerNetworkInfo checks if the daemon VIF routes any subnets. If it does, then the DNS IP assigned to the VIF and the network name of the teleroute network is returned. Otherwise, the method returns the daemon's IP on the default bridge as the DNS address and an empty string as the network name.

func LaunchDaemon

func LaunchDaemon(ctx context.Context, daemonID *daemon.Identifier) (info *daemon.Info, conn *grpc.ClientConn, err error)

LaunchDaemon ensures that the image returned by ClientImage exists by calling PullImage. It then uses the options DaemonOptions and DaemonArgs to start the image, and finally connectDaemon to connect to it. A successful start yields a cache.Info entry in the cache.

func NetworkPluginName added in v2.23.0

func NetworkPluginName(ctx context.Context) string

func PullImage

func PullImage(ctx context.Context, image string) error

PullImage checks if the given image exists locally by doing docker image inspect. A docker pull is performed if no local image is found. Stdout is silenced during those operations.

func RemoveVolumes added in v2.23.0

func RemoveVolumes(ctx context.Context, vols []string)

func StopContainer added in v2.13.0

func StopContainer(ctx context.Context, nameOrID string) error

func WaitForExit added in v2.23.0

func WaitForExit(ctx context.Context, cli *dockerClient.Client, id string, maxTime time.Duration) error

Types

type ContainerInfo added in v2.23.0

type ContainerInfo struct {
	ID   string
	Name string
	Pid  int
	IP   netip.Addr
}

func GetContainerInfo added in v2.23.0

func GetContainerInfo(ctx context.Context, cid string, network string) (*ContainerInfo, error)

GetContainerInfo returns the name and process ID of the container with the given ID along with its associated IP in the given network.

func Start added in v2.23.3

func Start(ctx context.Context, daemonInContainer bool, args ...string) (cni *ContainerInfo, cc *exec.Cmd, err error)

Directories

Path Synopsis
Package teleroute contains the Telepresence Daemon Teleroute service that the Docker Network Plugin with the same name connects to.
Package teleroute contains the Telepresence Daemon Teleroute service that the Docker Network Plugin with the same name connects to.

Jump to

Keyboard shortcuts

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