docker

package
v0.15.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebouncedNetworkCleanUp = _debounceNetworkCleanUp()
View Source
var DockerClient *client.Client
View Source
var DockerContext context.Context
View Source
var DockerIsConnected = false
View Source
var DockerNetworkLock = make(chan bool, 1)

use a semaphore lock

View Source
var DockerNetworkName = "cosmos-network"
View Source
var ExportError = ""

Functions

func AddLabels

func AddLabels(containerConfig types.ContainerJSON, labels map[string]string) error

func AttachNetwork

func AttachNetwork(w http.ResponseWriter, req *http.Request)

func AttachNetworkToCosmos

func AttachNetworkToCosmos(newNeworkName string) error

func AutoUpdateContainerRoute

func AutoUpdateContainerRoute(w http.ResponseWriter, req *http.Request)

func BootstrapAllContainersFromTags

func BootstrapAllContainersFromTags() []error

func BootstrapContainerFromTags

func BootstrapContainerFromTags(containerID string) error

func CanUpdateImageRoute

func CanUpdateImageRoute(w http.ResponseWriter, req *http.Request)

func CheckDockerNetworkMode added in v0.14.0

func CheckDockerNetworkMode() string

func CheckPorts

func CheckPorts() error

func CheckPuppetDB added in v0.14.0

func CheckPuppetDB()

func CheckUpdatesAvailable

func CheckUpdatesAvailable() map[string]bool

func Connect

func Connect() error

func ConnectToNetworkIfNotConnected

func ConnectToNetworkIfNotConnected(containerConfig types.ContainerJSON, networkName string) error

func ConnectToNetworkSync

func ConnectToNetworkSync(networkName string, containerID string) error

func ConnectToSecureNetwork

func ConnectToSecureNetwork(containerConfig types.ContainerJSON) (bool, error)

func ContainersIdRoute

func ContainersIdRoute(w http.ResponseWriter, req *http.Request)

func ContainersRoute

func ContainersRoute(w http.ResponseWriter, req *http.Request)

func CreateCosmosNetwork

func CreateCosmosNetwork(name string) (string, error)

func CreateLinkNetwork

func CreateLinkNetwork(containerName string, container2Name string) error

func CreateNetworkRoute

func CreateNetworkRoute(w http.ResponseWriter, req *http.Request)

func CreateReasonableNetwork added in v0.15.0

func CreateReasonableNetwork(name string, networkDef types.NetworkCreate) (types.NetworkCreateResponse, error)

func CreateService

func CreateService(serviceRequest DockerServiceCreateRequest, OnLog func(string)) error

func CreateServiceRoute

func CreateServiceRoute(w http.ResponseWriter, req *http.Request)

func CreateVolumeRoute

func CreateVolumeRoute(w http.ResponseWriter, req *http.Request)

func DebouncedExportDocker added in v0.11.0

func DebouncedExportDocker()

func DeleteNetworkRoute

func DeleteNetworkRoute(w http.ResponseWriter, req *http.Request)

func DeleteVolumeRoute

func DeleteVolumeRoute(w http.ResponseWriter, req *http.Request)

func DetachNetwork

func DetachNetwork(w http.ResponseWriter, req *http.Request)

func DockerListenEvents

func DockerListenEvents() error

func DockerPullImage added in v0.9.12

func DockerPullImage(image string) (io.ReadCloser, error)

func DoesContainerExist added in v0.14.1

func DoesContainerExist(containerName string) bool

func EditContainer

func EditContainer(oldContainerID string, newConfig types.ContainerJSON, noLock bool) (string, error)

func ExportContainerRoute added in v0.14.0

func ExportContainerRoute(w http.ResponseWriter, req *http.Request)

func ExportDocker added in v0.11.0

func ExportDocker()

func GetAllPorts

func GetAllPorts(container types.ContainerJSON) []string

func GetContainerIPByName added in v0.12.0

func GetContainerIPByName(containerName string) (ip string, err error)

func GetContainerLogsRoute

func GetContainerLogsRoute(w http.ResponseWriter, req *http.Request)

func GetContainerRoute

func GetContainerRoute(w http.ResponseWriter, req *http.Request)

func GetEnv added in v0.14.0

func GetEnv(env []string, key string) string

func GetLabel

func GetLabel(containerConfig types.ContainerJSON, label string) string

func HasAutoUpdateOn

func HasAutoUpdateOn(containerConfig types.ContainerJSON) bool

func HasLabel

func HasLabel(containerConfig types.ContainerJSON, label string) bool

func InspectContainer added in v0.14.0

func InspectContainer(containerName string) (types.ContainerJSON, error)

func InspectImageRoute

func InspectImageRoute(w http.ResponseWriter, req *http.Request)

func IsConnectedToASecureCosmosNetwork

func IsConnectedToASecureCosmosNetwork(self types.ContainerJSON, containerConfig types.ContainerJSON) (bool, error, bool)

func IsConnectedToNetwork

func IsConnectedToNetwork(containerConfig types.ContainerJSON, networkName string) bool

func IsLabel

func IsLabel(containerConfig types.ContainerJSON, label string) bool

func ListContainerNetworks

func ListContainerNetworks(w http.ResponseWriter, req *http.Request)

func ListContainers

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

func ListContainersRoute

func ListContainersRoute(w http.ResponseWriter, req *http.Request)

func ListNetworksRoute

func ListNetworksRoute(w http.ResponseWriter, req *http.Request)

func ListVolumeRoute

func ListVolumeRoute(w http.ResponseWriter, req *http.Request)

func ManageContainerRoute

func ManageContainerRoute(w http.ResponseWriter, req *http.Request)

func MigrateToHostModeRoute added in v0.14.0

func MigrateToHostModeRoute(w http.ResponseWriter, req *http.Request)

func NetworkCleanUp

func NetworkCleanUp()

func NetworkContainerRoutes

func NetworkContainerRoutes(w http.ResponseWriter, req *http.Request)

func NetworkRoutes

func NetworkRoutes(w http.ResponseWriter, req *http.Request)

func PullImage

func PullImage(w http.ResponseWriter, req *http.Request)

func PullImageIfMissing

func PullImageIfMissing(w http.ResponseWriter, req *http.Request)

func RecreateContainer

func RecreateContainer(containerID string, containerConfig types.ContainerJSON) (string, error)

func RecreateDepedencies

func RecreateDepedencies(containerID string)

func RemoveLabels

func RemoveLabels(containerConfig types.ContainerJSON, labels []string) error

func RemoveSelfUpdater

func RemoveSelfUpdater() error

func RestartContainer added in v0.15.0

func RestartContainer(containerName string)

func Rollback

func Rollback(actions []DockerServiceCreateRollback, OnLog func(string))

func SecureContainerRoute

func SecureContainerRoute(w http.ResponseWriter, req *http.Request)

func SelfAction added in v0.14.0

func SelfAction(action string) error

func SelfRecreate

func SelfRecreate() error

func StopContainer added in v0.12.0

func StopContainer(containerName string)

func TerminalRoute

func TerminalRoute(w http.ResponseWriter, r *http.Request)

func Test

func Test() error

func UnexposeAllPorts

func UnexposeAllPorts(container *types.ContainerJSON) error

func UnsecureContainer

func UnsecureContainer(container types.ContainerJSON) (string, error)

func UpdateContainerRoute

func UpdateContainerRoute(w http.ResponseWriter, req *http.Request)

func UpdatePorts

func UpdatePorts(finalPorts []string) error

func VolumesRoute

func VolumesRoute(w http.ResponseWriter, req *http.Request)

Types

type Cache added in v0.12.0

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

func NewCache added in v0.12.0

func NewCache() *Cache

func (*Cache) Get added in v0.12.0

func (c *Cache) Get(key string) (string, bool)

func (*Cache) Set added in v0.12.0

func (c *Cache) Set(key string, value string, duration time.Duration)

type ContainerCreateRequestContainer

type ContainerCreateRequestContainer struct {
	Name        string                                          `json:"container_name"`
	Image       string                                          `json:"image"`
	Environment []string                                        `json:"environment"`
	Labels      map[string]string                               `json:"labels"`
	Ports       []string                                        `json:"ports"`
	Volumes     []mount.Mount                                   `json:"volumes"`
	Networks    map[string]ContainerCreateRequestServiceNetwork `json:"networks"`
	Routes      []utils.ProxyRouteConfig                        `json:"routes"`
	Links       []string                                        `json:"links,omitempty"`

	RestartPolicy string   `json:"restart,omitempty"`
	Devices       []string `json:"devices"`
	Expose        []string `json:"expose"`
	DependsOn     []string `json:"depends_on"`
	Tty           bool     `json:"tty,omitempty"`
	StdinOpen     bool     `json:"stdin_open,omitempty"`

	Command         string                                     `json:"command,omitempty"`
	Entrypoint      string                                     `json:"entrypoint,omitempty"`
	WorkingDir      string                                     `json:"working_dir,omitempty"`
	User            string                                     `json:"user,omitempty"`
	UID             int                                        `json:"uid,omitempty"`
	GID             int                                        `json:"gid,omitempty"`
	Hostname        string                                     `json:"hostname,omitempty"`
	Domainname      string                                     `json:"domainname,omitempty"`
	MacAddress      string                                     `json:"mac_address,omitempty"`
	Privileged      bool                                       `json:"privileged,omitempty"`
	NetworkMode     string                                     `json:"network_mode,omitempty"`
	StopSignal      string                                     `json:"stop_signal,omitempty"`
	StopGracePeriod int                                        `json:"stop_grace_period,omitempty"`
	HealthCheck     ContainerCreateRequestContainerHealthcheck `json:"healthcheck,omitempty"`
	DNS             []string                                   `json:"dns,omitempty"`
	DNSSearch       []string                                   `json:"dns_search,omitempty"`
	ExtraHosts      []string                                   `json:"extra_hosts,omitempty"`
	SecurityOpt     []string                                   `json:"security_opt,omitempty"`
	StorageOpt      map[string]string                          `json:"storage_opt,omitempty"`
	Sysctls         map[string]string                          `json:"sysctls,omitempty"`
	Isolation       string                                     `json:"isolation,omitempty"`

	CapAdd  []string `json:"cap_add,omitempty"`
	CapDrop []string `json:"cap_drop,omitempty"`

	PostInstall []string `json:"post_install,omitempty"`
}

func ExportContainer added in v0.14.0

func ExportContainer(containerID string) (ContainerCreateRequestContainer, error)

type ContainerCreateRequestContainerHealthcheck added in v0.11.0

type ContainerCreateRequestContainerHealthcheck struct {
	Test        []string `json:"test"`
	Interval    int      `json:"interval"`
	Timeout     int      `json:"timeout"`
	Retries     int      `json:"retries"`
	StartPeriod int      `json:"start_period"`
}

type ContainerCreateRequestNetwork

type ContainerCreateRequestNetwork struct {
	// name must be unique
	Name       string            `json:"name"`
	Driver     string            `json:"driver"`
	Attachable bool              `json:"attachable"`
	Internal   bool              `json:"internal"`
	EnableIPv6 bool              `json:"enable_ipv6"`
	Labels     map[string]string `json:"labels"`
	IPAM       struct {
		Driver string                                    `json:"driver"`
		Config []ContainerCreateRequestNetworkIPAMConfig `json:"config"`
	} `json:"ipam"`
}

type ContainerCreateRequestNetworkIPAMConfig added in v0.11.0

type ContainerCreateRequestNetworkIPAMConfig struct {
	Subnet  string `json:"subnet"`
	Gateway string `json:"gateway"`
}

type ContainerCreateRequestServiceNetwork

type ContainerCreateRequestServiceNetwork struct {
	Aliases     []string `json:"aliases,omitempty"`
	IPV4Address string   `json:"ipv4_address,omitempty"`
	IPV6Address string   `json:"ipv6_address,omitempty"`
}

type ContainerCreateRequestVolume

type ContainerCreateRequestVolume struct {
	// name must be unique
	Name   string `json:"name"`
	Driver string `json:"driver"`
	Source string `json:"source"`
	Target string `json:"target"`
}

type ContainerForm

type ContainerForm struct {
	Image         string            `json:"image"`
	User          string            `json:"user"`
	RestartPolicy string            `json:"restartPolicy"`
	Env           []string          `json:"envVars"`
	Devices       []string          `json:"devices"`
	Labels        map[string]string `json:"labels"`
	PortBindings  nat.PortMap       `json:"portBindings"`
	Volumes       []mount.Mount     `json:"Volumes"`
	// we make this a int so that we can ignore 0
	Interactive int    `json:"interactive"`
	NetworkMode string `json:"networkMode"`
}

type ContainerStats added in v0.12.0

type ContainerStats struct {
	Name      string
	CPUUsage  float64
	MemUsage  uint64
	MemLimit  uint64
	NetworkRx float64
	NetworkTx float64
}

func Stats added in v0.12.0

func Stats(container types.Container) (ContainerStats, error)

func StatsAll added in v0.12.0

func StatsAll() ([]ContainerStats, error)

type DockerServiceCreateRequest

type DockerServiceCreateRequest struct {
	Services map[string]ContainerCreateRequestContainer `json:"services"`
	Volumes  map[string]ContainerCreateRequestVolume    `json:"volumes"`
	Networks map[string]ContainerCreateRequestNetwork   `json:"networks"`
}

func RunDB added in v0.14.0

type DockerServiceCreateRollback

type DockerServiceCreateRollback struct {
	// action: disconnect, remove, etc...
	Action string `json:"action"`
	// type: container, volume, network
	Type string `json:"type"`
	// name: container name, volume name, network name
	Name string `json:"name"`
	// was: container old settings
	Was doctype.ContainerJSON `json:"was"`
}

type LogOutput

type LogOutput struct {
	StreamType byte   `json:"streamType"`
	Size       uint32 `json:"size"`
	Output     string `json:"output"`
}

func FilterLogs

func FilterLogs(logReader io.Reader, searchQuery string, limit int) []LogOutput

func ParseDockerLogHeader

func ParseDockerLogHeader(data []byte) LogOutput

ParseDockerLogHeader parses the first 8 bytes of a Docker log message and returns the stream type, size, and the rest of the message as output. It also checks if the message contains a log header and extracts the log message from it.

type VolumeCreateRequest

type VolumeCreateRequest struct {
	Name   string `json:"name"`
	Driver string `json:"driver"`
}

Jump to

Keyboard shortcuts

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