Skip to main content

Class: Host

Information about the host environment.

Extends

  • BaseClient

Constructors

Constructor

new Host(ctx?, _id?, _findUp?): Host

Constructor is used for internal usage only, do not create object from it.

Parameters

ctx?

Context

_id?

ID

_findUp?

string

Returns

Host

Overrides

BaseClient.constructor

Methods

containerImage()

containerImage(name): Container

Accesses a container image on the host.

Parameters

name

string

Name of the image to access.

Returns

Container


directory()

directory(path, opts?): Directory

Accesses a directory on the host.

Parameters

path

string

Location of the directory to access (e.g., ".").

opts?

HostDirectoryOpts

Returns

Directory


file()

file(path, opts?): File

Accesses a file on the host.

Parameters

path

string

Location of the file to retrieve (e.g., "README.md").

opts?

HostFileOpts

Returns

File


findUp()

findUp(name, opts?): Promise<string>

Search for a file or directory by walking up the tree from system workdir. Return its relative path. If no match, return null

Parameters

name

string

name of the file or directory to search for

opts?

HostFindUpOpts

Returns

Promise<string>


id()

id(): Promise<ID>

A unique identifier for this Host.

Returns

Promise<ID>


service()

service(ports, opts?): Service

Creates a service that forwards traffic to a specified address via the host.

Parameters

ports

PortForward[]

Ports to expose via the service, forwarding through the host network.

If a port's frontend is unspecified or 0, it defaults to the same as the backend port.

An empty set of ports is not valid; an error will be returned.

opts?

HostServiceOpts

Returns

Service


tunnel()

tunnel(service, opts?): Service

Creates a tunnel that forwards traffic from the host to a service.

Parameters

service

Service

Service to send traffic from the tunnel.

opts?

HostTunnelOpts

Returns

Service


unixSocket()

unixSocket(path): Socket

Accesses a Unix socket on the host.

Parameters

path

string

Location of the Unix socket (e.g., "/var/run/docker.sock").

Returns

Socket