docker

package
v0.10.0-unstable19 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: Apache-2.0 Imports: 33 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"

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 CheckPorts

func CheckPorts() error

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

func CreateLinkNetwork

func CreateLinkNetwork(containerName string, container2Name string) error

func CreateNetworkRoute

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

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 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 EditContainer

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

func GetAllPorts

func GetAllPorts(container types.ContainerJSON) []string

func GetContainerLogsRoute

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

func GetContainerRoute

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

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 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 NetworkCleanUp

func NetworkCleanUp()

func NetworkContainerRoutes

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

func NetworkRoutes

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

func NewDB

func NewDB(w http.ResponseWriter, req *http.Request) (string, error)

func NewDBRoute

func NewDBRoute(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 Rollback

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

func RunContainer

func RunContainer(imagename string, containername string, inputEnv []string, volumes []VolumeMount) error

func SecureContainerRoute

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

func SelfRecreate

func SelfRecreate() error

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 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     struct {
		Test        []string `json:"test"`
		Interval    int      `json:"interval"`
		Timeout     int      `json:"timeout"`
		Retries     int      `json:"retries"`
		StartPeriod int      `json:"start_period"`
	} `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"`
	SysctlsMap map[string]string `json:"sysctls,omitempty"`

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

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"`
	IPAM       struct {
		Driver string `json:"driver"`
		Config []struct {
			Subnet string `json:"subnet"`
		} `json:"config"`
	} `json:"ipam"`
}

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"`
	RestartPolicy string            `json:"restartPolicy"`
	Env           []string          `json:"envVars"`
	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 DockerServiceCreateRequest

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

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"`
}

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"`
}

type VolumeMount

type VolumeMount struct {
	Destination string
	Volume      *types.Volume
}

Jump to

Keyboard shortcuts

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