docker

package
v0.0.0-...-10f32d8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckContainerStatus

func CheckContainerStatus(containerName string) (bool, bool, error)

CheckContainerStatus checks if a container with the given name exists and is running

func CheckIfInitialized

func CheckIfInitialized() error

CheckIfInitialized checks if the Docker client is initialized

func CheckIfNetworkExists

func CheckIfNetworkExists(networkName string) (bool, error)

func ContainerCommandParamsToConfig

func ContainerCommandParamsToConfig(cmdParams ContainerCommandParams) (*container.Config, error)

func CreateContainer

func CreateContainer(cmdParams ContainerCommandParams) (string, error)

CreateContainer creates a container with the given parameters

func DeleteContainerImage

func DeleteContainerImage(imageID string) error

DeleteContainerImage deletes an image from the Docker engine

func ExportImageFromEngine

func ExportImageFromEngine(imageID string) (io.ReadCloser, error)

ExportImageFromEngine exports an image from the Docker engine and returns it as an io.Reader

func GetContainerInfo

func GetContainerInfo(containerID string) (types.ContainerJSON, error)

GetContainerInfo returns information about a container

func GetContainerLogs

func GetContainerLogs(containerID string) (string, error)

GetContainerLogs returns the logs of a container

func GetImageID

func GetImageID(imageName string) (string, error)

func GetImageInfo

func GetImageInfo(imageID string) (*types.ImageInspect, error)

From an ID, get the all the information about the image

func GetImageName

func GetImageName(imageID string) (string, error)

GetImageName returns the name of an image

func GetImageSize

func GetImageSize(imageID string) (int64, error)

GetImageSize returns the size of an image

func GetImageSizeFromReader

func GetImageSizeFromReader(imageID string) (int64, error)

func GetImageTag

func GetImageTag(imageID string) (string, error)

GetImageTag returns the tag of an image

func GetNetworkInfo

func GetNetworkInfo(networkName string) (types.NetworkResource, error)

GetNetworkInfo returns information about a network

func ImportImageToEngine

func ImportImageToEngine(imageFilePath string) error

ImportImageToEngine imports an image to the Docker engine

func IsRunningInContainer

func IsRunningInContainer() bool

func ListContainerImages

func ListContainerImages() ([]types.ImageSummary, error)

func ListRunningContainers

func ListRunningContainers() ([]types.Container, error)

ListRunningContainers lists all running containers

func RemoveContainer

func RemoveContainer(containerID string) error

RemoveContainer

func RenameContainer

func RenameContainer(containerID string, newName string) error

RenameContainer renames a container with the given name

func StartContainer

func StartContainer(containerID string) error

StartContainer starts a container

func StopContainer

func StopContainer(containerID string) error

StopContainer try to stop a container gracefully, if it fails, it will stop it forcefully

func StopContainerGracefully

func StopContainerGracefully(containerID string, timeoutDuration time.Duration) (bool, error)

StopContainerGracefully stops a container by sending a SIGTERM and waiting for it to stop

func StopContainerRagefully

func StopContainerRagefully(containerID string) error

StopContainerRagefully stops a container by sending a SIGKILL

func UpdateContainerConfig

func UpdateContainerConfig(containerID string, newConfig *container.Config, newHostConfig *container.HostConfig, newNetworkingConfig *network.NetworkingConfig) error

UpdateContainerConfig updates the configuration of an existing container.

func WhoAmI

func WhoAmI() (string, error)

WhoAmI attempts to identify the Docker image digest of the container running this code.

Types

type Config

type Config struct {
	Sock         string
	PodmanEnable bool
}

type ContainerCommandParams

type ContainerCommandParams struct {
	ContainerName string
	ContainerHost string
	Domain        string
	ServiceName   string
	IsSSL         bool
	EnvVar        string
	ImageName     string
	ImageID       string
	PortMappings  []PortMapping
	Volumes       []string
	Labels        []string
	Network       string
	Restart       string
	Environment   []string
}

type ContainerEngineClient

type ContainerEngineClient interface {
	InitializeClient(*Config) error
}

type DockerClient

type DockerClient struct{}

DockerClient implements the ContainerEngineClient interface for Docker

func (*DockerClient) InitializeClient

func (d *DockerClient) InitializeClient(config *Config) error

type PortMapping

type PortMapping struct {
	HostPort      string
	ContainerPort string
	Protocol      string
}

func ParsePortsSpecs

func ParsePortsSpecs(portsSpecs []string) ([]PortMapping, error)

ParsePortsSpecs receives a slice of strings in the format "hostPort:containerPort/Protocol" and returns a slice of PortMapping structs

Jump to

Keyboard shortcuts

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