docker

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDockerAPIIsUnreachable occurs when Docker is not running
	// or the user who runs the application cannot call Docker API.
	ErrDockerAPIIsUnreachable = func(err error) error {
		return fmt.Errorf("docker api is unreachable: %w", err)
	}

	// ErrDockerVersionMismatch occurs when the Docker version is too old.
	ErrDockerVersionMismatch = func(s string) error {
		return fmt.Errorf("docker version is too old: %s", s)
	}

	// ErrCannotFindContainer occurs when the application cannot find the requested container.
	ErrCannotFindContainer = func(s string, err error) error {
		return fmt.Errorf("cannot find container: %s, error: %w", s, err)
	}

	// ErrNoContainersFound occurs when the application found zero containers.
	ErrNoContainersFound = func() error {
		return fmt.Errorf("no containers found")
	}

	// ErrTooManyContainersFound occurs when the application found more than 1 container.
	ErrTooManyContainersFound = func(s string) error {
		return fmt.Errorf("too many containers found: %s", s)
	}

	// ErrCannotFindNetwork occurs when the application cannot find the requested network during container inspection.
	ErrCannotFindNetwork = func(s string) error {
		return fmt.Errorf("cannot find network: %s", s)
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*dockerpkg.Client
}

func Must

func Must(c *Client, err error) *Client

func NewClient

func NewClient(dockerHost string) (*Client, error)

NewClient creates a docker client and return with it.

func (*Client) AppName

func (c *Client) AppName() string

func (*Client) Check

func (c *Client) Check() error

Check checks if docker-engine is running or not.

func (*Client) ContainerAddressInNetwork

func (c *Client) ContainerAddressInNetwork(containerName, environmentName, networkName string) (string, error)

ContainerAddressInNetwork returns the container IP address in the specific network.

func (*Client) ContainerGatewayInNetwork

func (c *Client) ContainerGatewayInNetwork(containerName, networkName string) (string, error)

ContainerGatewayInNetwork returns the container IP address in the specific network.

func (*Client) ContainerIDByName

func (c *Client) ContainerIDByName(containerName string) (string, error)

ContainerIDByName returns a container ID of the containerName running in the current environment.

func (*Client) ContainerNamesByName

func (c *Client) ContainerNamesByName(containerName string) ([]string, error)

ContainerNamesByName returns a container names of the containerName running in the current environment.

func (*Client) ContainerRunning

func (c *Client) ContainerRunning(container string) bool

ContainerRunning returns true if container is running.

func (*Client) ContainerStateByName

func (c *Client) ContainerStateByName(containerName string) (string, error)

ContainerStateByName returns the container state of the containerName running in the current environment.

func (*Client) EnvName

func (c *Client) EnvName() string

func (*Client) NetworkExist

func (c *Client) NetworkExist(networkName string) (bool, error)

NetworkExist returns true if the docker network exists.

func (*Client) NetworkNamesByLabel

func (c *Client) NetworkNamesByLabel(label string) ([]string, error)

NetworkNamesByLabel returns a list of network names that have the specified label.

Jump to

Keyboard shortcuts

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