Categorygithub.com/containerssh/dockerrun
modulepackage
0.9.2
Repository: https://github.com/containerssh/dockerrun.git
Documentation: pkg.go.dev

# README

ContainerSSH - Launch Containers on Demand

ContainerSSH DockerRun Backend Library

Go Report Card LGTM Alerts

This library implements a backend that connects to a Docker socket and launches a new container for each connection, then runs executes a separate command per channel.

Note: This is a developer documentation.
The user documentation for ContainerSSH is located at containerssh.github.io.

Using this library

This library implements a NetworkConnectionHandler from the sshserver library. This can be embedded into a connection handler.

The network connection handler can be created with the New() method:

var client net.TCPAddr
connectionID := "0123456789ABCDEF"
config := dockerrun.Config{
    //...
}
dr, err := dockerrun.New(client, connectionID, config, logger)
if err != nil {
    // Handle error
}

The logger parameter is a logger from the ContainerSSH logger library.

The dr variable can then be used to create a container on finished handshake:

ssh, err := dr.OnHandshakeSuccess("provided-connection-username")

Conversely, on disconnect you must call dr.OnDisconnect(). The ssh variable can then be used to create session channels:

var channelID uint64 = 0
extraData := []byte{}
session, err := ssh.OnSessionChannel(channelID, extraData)

Finally, the session can be used to launch programs:

var requestID uint64 = 0
err = session.OnEnvRequest(requestID, "foo", "bar")
// ...
requestID = 1
var stdin io.Reader
var stdout, stderr io.Writer
err = session.OnShell(
    requestID,
    stdin,
    stdout,
    stderr,
    func(exitStatus ExitStatus) {
        // ...
    },
)

# Functions

New creates a new NetworkConnectionHandler for a specific client.goland:noinspection GoUnusedExportedFunction.

# Constants

ImagePullPolicyAlways means that the container image will be pulled on every connection.
ImagePullPolicyIfNotPresent means the image will be pulled if the image is not present locally, an empty tag, or the "latest" tag was specified.
ImagePullPolicyNever means that the image will be never pulled, and if the image is not available locally the connection will fail.

# Structs

Config is the base configuration structure of the DockerRun backend.
ContainerConfig contains the configuration of what container to run in Docker.

# Type aliases

No description provided by the author