docker

package
v0.0.0-...-25f02fd Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Purge

func Purge() error

Purge removes all Docker objects created by norma.

Types

type Client

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

Client provides means to spawn Docker containers capable of hosting services like the go-opera client.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new client facilitating the creation of Docker Containers capable of hosting services. Clients successfully created through this function should be Closed() eventually.

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateBridgeNetwork

func (c *Client) CreateBridgeNetwork() (*Network, error)

CreateBridgeNetwork creates a new Docker bridge network.

func (*Client) Start

func (c *Client) Start(config *ContainerConfig) (*Container, error)

Start creates and runs one Container. The provided configuration allows to configure the Docker image to run inside the container -- and thus the services to be offered -- and port-forwarding specifications to make those services reachable from outside the Docker container (e.g. by the application running this code).

type Container

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

Container represents a Docker Container, typically used for running a Fantom network Node, thus an instance of the go-opera client. *Container implements the driver.Host interface.

func (*Container) Cleanup

func (c *Container) Cleanup() error

Cleanup stops the container (unless it is already stopped) and frees any resources associated to it. After the operation, the Container is to be considered invalid.

func (*Container) Exec

func (c *Container) Exec(cmd []string) (string, error)

Exec executes a command in the container. This method is blocking until the command has finished. The output of the command is returned as a string (stdout + stderr). The command is required to be tokenized and interpreted in shell's exec form.

func (*Container) GetAddressForService

func (c *Container) GetAddressForService(service *network.ServiceDescription) *network.AddressPort

GetAddressForService retrieves the Address of a service running in this Container and being exported to the Docker's host environment. If there is no such service (e.g., because it was not marked as to be exported during the Start of the Container), nil will be returned.

func (*Container) Hostname

func (c *Container) Hostname() string

Hostname returns the hostname of the Container. In this case it is the ID of the Docker Container.

func (*Container) IsRunning

func (c *Container) IsRunning() bool

IsRunning returns true if the Container has not been stopped yet and is expected to offer its services.

func (*Container) SaveLogTo

func (c *Container) SaveLogTo(directory string) error

SaveLogTo fetches the log of the container and saves it to the given directory.

func (*Container) SendSignal

func (c *Container) SendSignal(signal Signal) error

SendSignal sends a signal to the container.

func (*Container) Stop

func (c *Container) Stop() error

Stop terminates this container. Services within the container will be signaled about the upcoming termination followed by being killed after a set timeout (see ContainerConfig.ShutdownTimeout).

func (*Container) StreamLog

func (c *Container) StreamLog() (io.ReadCloser, error)

type ContainerConfig

type ContainerConfig struct {
	ImageName       string
	ShutdownTimeout *time.Duration
	PortForwarding  map[network.Port]network.Port // Container Port => Host Port
	Environment     map[string]string
	Entrypoint      []string // Entrypoint to run when starting the container. Optional.
	Network         *Network // Docker network to join, nil to join bridge network
	DataDirBinding  *string  // mount client datadir to this path on host
}

ContainerConfig defines parameters for running Docker Containers.

type Network

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

Network represents a Docker network. It is used to connect Containers to each other.

func (*Network) Cleanup

func (n *Network) Cleanup() error

Cleanup removes the network from the Docker host.

type Signal

type Signal string

Signal represents a signal that can be sent to a Docker container.

var SigHup Signal = "SIGHUP"

SigHup is the SIGHUP signal.

var SigInt Signal = "SIGINT"
var SigKill Signal = "SIGKILL"
var Sigterm Signal = "SIGTERM"

Jump to

Keyboard shortcuts

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