dockerapi

package
v1.1.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandListenStream

func ExpandListenStream(listen, runtimeDir string, uid int) string

ExpandListenStream expands systemd ListenStream specifiers (%t, %i).

func ParseDockerHost

func ParseDockerHost(host string) (path string, ok bool)

ParseDockerHost extracts a unix filesystem path from DOCKER_HOST or docker context host.

func ParseSystemdShow

func ParseSystemdShow(out, runtimeDir string, uid int) (path string, ok bool)

ParseSystemdShow extracts ListenStream path from systemctl show output.

Types

type Client

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

Client wraps docker/docker client with helpers.

func NewFromHost

func NewFromHost(ctx context.Context, host string) (*Client, error)

NewFromHost connects to Docker at host (e.g. tcp://127.0.0.1:PORT from tunnel).

func NewLocal

func NewLocal(ctx context.Context) (*Client, error)

NewLocal connects to local Docker via DOCKER_HOST or default unix socket.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Host

func (c *Client) Host() string

Host returns the configured API host string.

func (*Client) Moby

func (c *Client) Moby() *client.Client

Moby returns the underlying docker client.

type Pair

type Pair struct {
	Local  *Client
	Remote *RemoteSession
}

Pair holds local and optional remote docker clients for a deploy session.

func OpenPair

func OpenPair(ctx context.Context, needLocal bool, remote *RemoteSession) (*Pair, error)

OpenPair opens local client (when needed) and remote session via SSH tunnel.

func (*Pair) Close

func (p *Pair) Close()

Close closes all clients in the pair.

type RemoteSession

type RemoteSession struct {
	Tunnel *Tunnel
	Client *Client
	Socket ResolvedSocket
}

RemoteSession holds SSH tunnel and docker API client for remote host.

func OpenRemote

func OpenRemote(ctx context.Context, sshClient *ssh.Client, cfg *config.Config) (*RemoteSession, error)

OpenRemote opens tunnel + docker client after resolving socket.

func TryOpenRemote

func TryOpenRemote(ctx context.Context, sshClient *ssh.Client, cfg *config.Config) (*RemoteSession, error)

TryOpenRemote opens remote API session; returns nil session on failure (for optional optimization).

func (*RemoteSession) Close

func (s *RemoteSession) Close() error

Close closes client and tunnel.

type ResolvedSocket

type ResolvedSocket struct {
	Path   string
	Source string
}

ResolvedSocket holds auto-detected remote docker socket path.

func ResolveRemoteSocket

func ResolveRemoteSocket(sshClient *ssh.Client, cfg *config.Config) (ResolvedSocket, error)

ResolveRemoteSocket determines unix socket path on remote host via SSH.

type Tunnel

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

Tunnel proxies local TCP to remote unix socket over SSH streamlocal.

func StartTunnel

func StartTunnel(sshClient *ssh.Client, socketPath string) (*Tunnel, error)

StartTunnel listens on 127.0.0.1:0 and forwards to remote unix socket.

func (*Tunnel) Close

func (t *Tunnel) Close() error

Close stops the tunnel listener.

func (*Tunnel) Host

func (t *Tunnel) Host() string

Host returns tcp://127.0.0.1:PORT for docker client.

Jump to

Keyboard shortcuts

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