docker

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: GPL-3.0 Imports: 18 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 CheckIfImageExists

func CheckIfImageExists(imageID string) (bool, error)

CheckIfImageExists checks if an image exists in the Docker engine

func CheckIfInitialized

func CheckIfInitialized() error

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 GetAllImages

func GetAllImages() ([]image.Summary, error)

list all images

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 GetContainerName

func GetContainerName(containerID string) (string, error)

GetContainerName returns the name of a container

func GetImageIDByName

func GetImageIDByName(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) (string, error)

ImportImageToEngine imports an image to the Docker engine and returns the image ID

func InitializeClient

func InitializeClient(config *Config) error

func IsRunningInContainer

func IsRunningInContainer() bool

func ListContainerImages

func ListContainerImages() ([]image.Summary, error)

func ListContainers

func ListContainers(ctx context.Context) ([]types.Container, 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
	TraefikEntryPoint string
}

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