Documentation
¶
Index ¶
- Constants
- Variables
- func AddLabels(containerConfig types.ContainerJSON, labels map[string]string) error
- func ApplyComposeRoutes(spec DockerServiceCreateRequest) bool
- func AttachNetwork(w http.ResponseWriter, req *http.Request)
- func AttachNetworkToCosmos(newNeworkName string) error
- func AutoUpdateContainerRoute(w http.ResponseWriter, req *http.Request)
- func BootstrapAllContainersFromTags() []error
- func BootstrapContainerFromTags(containerID string) error
- func CanUpdateImageRoute(w http.ResponseWriter, req *http.Request)
- func CheckDockerNetworkMode() string
- func CheckPorts() error
- func CheckUpdatesAvailable() map[string]bool
- func CleanupExitedDeploymentContainers()
- func ComposeRoutes(spec DockerServiceCreateRequest) []utils.ProxyRouteConfig
- func ComposeRoutesAtVersion(spec DockerServiceCreateRequest, version int) bool
- func ComposeSpecHash(spec DockerServiceCreateRequest) string
- func Connect() error
- func ConnectToNetworkIfNotConnected(containerConfig types.ContainerJSON, networkName string) error
- func ConnectToNetworkSync(networkName string, containerID string) error
- func ConnectToSecureNetwork(containerConfig types.ContainerJSON) (bool, error)
- func ContainerIDsByDeploymentLabel(deploymentName string) ([]string, error)
- func ContainerIsRunning(containerID string) (bool, error)
- func ContainersIdRoute(w http.ResponseWriter, req *http.Request)
- func ContainersRoute(w http.ResponseWriter, req *http.Request)
- func CreateCosmosNetwork(name string) (string, error)
- func CreateLinkNetwork(containerName string, container2Name string) error
- func CreateNetworkRoute(w http.ResponseWriter, req *http.Request)
- func CreateReasonableNetwork(name string, networkDef types.NetworkCreate) (types.NetworkCreateResponse, error)
- func CreateService(serviceRequest DockerServiceCreateRequest, OnLog func(string)) error
- func CreateServiceRoute(w http.ResponseWriter, req *http.Request)
- func CreateVolumeRoute(w http.ResponseWriter, req *http.Request)
- func DebouncedExportDocker()
- func DeleteNetworkRoute(w http.ResponseWriter, req *http.Request)
- func DeleteVolumeRoute(w http.ResponseWriter, req *http.Request)
- func DeploymentRoutesLabelEntries(spec DockerServiceCreateRequest) []string
- func DeploymentRunningAtSpecHash(deploymentName string, containerNames []string, hash string) bool
- func DeploymentRunningAtVersion(deploymentName string, containerNames []string, version int) bool
- func DetachNetwork(w http.ResponseWriter, req *http.Request)
- func DockerListenEvents() error
- func DockerPullImage(image string) (io.ReadCloser, error)
- func DoesContainerExist(containerName string) bool
- func EditContainer(oldContainerID string, newConfig types.ContainerJSON, noLock bool) (string, error)
- func EffectiveDeploymentVersion(routes []utils.ProxyRouteConfig, labelVersion int, owners []string) int
- func EnsureLazyAwake(containerName string, port string, maxWait time.Duration) (bool, error)
- func ExportContainerRoute(w http.ResponseWriter, req *http.Request)
- func ExportDocker()
- func ForgetContainerIP(containerName string)
- func ForgetLocalNetworkSubnets()
- func GetAllPorts(container types.ContainerJSON) []string
- func GetContainerIPByName(containerName string) (ip string, err error)
- func GetContainerLogsRoute(w http.ResponseWriter, req *http.Request)
- func GetContainerRoute(w http.ResponseWriter, req *http.Request)
- func GetContainersUsingPath(path string) ([]string, error)
- func GetEnv(env []string, key string) string
- func GetLabel(containerConfig types.ContainerJSON, label string) string
- func HasAutoUpdateOn(containerConfig types.ContainerJSON) bool
- func HasLabel(containerConfig types.ContainerJSON, label string) bool
- func InspectContainer(containerName string) (types.ContainerJSON, error)
- func InspectImageRoute(w http.ResponseWriter, req *http.Request)
- func IsConnectedToASecureCosmosNetwork(self types.ContainerJSON, containerConfig types.ContainerJSON) (bool, error, bool)
- func IsConnectedToNetwork(containerConfig types.ContainerJSON, networkName string) bool
- func IsInsideContainer()
- func IsLabel(containerConfig types.ContainerJSON, label string) bool
- func IsLazyLabels(labels map[string]string) bool
- func IsLocalDockerIP(ip string) bool
- func LazyConnClose(containerName string)
- func LazyConnOpen(containerName string)
- func LazyContainerRoute(w http.ResponseWriter, req *http.Request)
- func LazyIsDormant(containerName string) bool
- func LazyTouch(containerName string)
- func ListContainerNetworks(w http.ResponseWriter, req *http.Request)
- func ListContainers() ([]types.Container, error)
- func ListContainersRoute(w http.ResponseWriter, req *http.Request)
- func ListDeploymentNamesRunningHere() ([]string, error)
- func ListDeploymentVersionsRunningHere() (map[string]int, error)
- func ListNetworksRoute(w http.ResponseWriter, req *http.Request)
- func ListVolumeRoute(w http.ResponseWriter, req *http.Request)
- func ManageContainerRoute(w http.ResponseWriter, req *http.Request)
- func MergeComposeRoutes(routes []utils.ProxyRouteConfig, spec DockerServiceCreateRequest, ...) ([]utils.ProxyRouteConfig, bool)
- func MigrateToHostModeRoute(w http.ResponseWriter, req *http.Request)
- func NetworkCleanUp()
- func NetworkContainerRoutes(w http.ResponseWriter, req *http.Request)
- func NetworkRoutes(w http.ResponseWriter, req *http.Request)
- func PullImage(w http.ResponseWriter, req *http.Request)
- func PullImageIfMissing(w http.ResponseWriter, req *http.Request)
- func RecreateContainer(containerID string, containerConfig types.ContainerJSON) (string, error)
- func RecreateDepedencies(containerID, containerName string)
- func RemoveByDeploymentLabel(deploymentName string, OnLog func(string), keepVolumes bool) []error
- func RemoveDeploymentRoutes(entries []string) int
- func RemoveLabels(containerConfig types.ContainerJSON, labels []string) error
- func RemoveSelfUpdater() error
- func RestartContainer(containerName string)
- func Rollback(actions []DockerServiceCreateRollback, OnLog func(string))
- func RouteNamesByDeploymentLabel(deploymentName string) ([]string, error)
- func SecureContainerRoute(w http.ResponseWriter, req *http.Request)
- func SelfAction(action string) error
- func SelfRecreate() error
- func StartContainers(containerIDs []string) error
- func StartLazyReaper()
- func StopContainer(containerName string)
- func StopContainers(containerIDs []string) error
- func StopLazyReaper()
- func TerminalRoute(w http.ResponseWriter, r *http.Request)
- func Test() error
- func UnexposeAllPorts(container *types.ContainerJSON) error
- func UnsecureContainer(container types.ContainerJSON) (string, error)
- func UpdateContainerRoute(w http.ResponseWriter, req *http.Request)
- func UpdatePorts(finalPorts []string) error
- func VolumesRoute(w http.ResponseWriter, req *http.Request)
- type Cache
- type ContainerCreateRequestContainer
- type ContainerCreateRequestContainerDependsOnCont
- type ContainerCreateRequestContainerHealthcheck
- type ContainerCreateRequestNetwork
- type ContainerCreateRequestNetworkIPAMConfig
- type ContainerCreateRequestServiceNetwork
- type ContainerCreateRequestVolume
- type ContainerForm
- type ContainerLiveness
- type ContainerStats
- type DockerServiceCreateRequest
- type DockerServiceCreateRollback
- type LogOutput
- type VolumeCreateRequest
Constants ¶
const ( LazyLabel = "cosmos-lazy" LazyIdleLabel = "cosmos-lazy-idle" LazyStartTimeoutLabel = "cosmos-lazy-start-timeout" LazyDefaultIdle = time.Hour LazyDefaultStartTimeout = 60 * time.Second LazyReaperInterval = 30 * time.Second LazyMaxWakeFailures = 3 )
const DeploymentKeepVolumesLabel = "cosmos-deployment-keep-volumes"
DeploymentKeepVolumesLabel ("true") marks a deployment as data-bearing: RemoveByDeploymentLabel preserves its named volumes regardless of the keepVolumes argument. Stamped on containers AND volumes.
const DeploymentLabel = "cosmos-deployment"
DeploymentLabel is the docker label key used to identify resources that belong to a scheduler-managed deployment. The value is the deployment name.
const DeploymentRoutesLabel = "cosmos-deployment-routes"
DeploymentRoutesLabel holds the comma-joined owner pairs ("kind:name") of the deployment's proxy routes, so teardown can withdraw them after the KV record is gone.
const DeploymentSpecHashLabel = "cosmos-deployment-spec-hash"
DeploymentSpecHashLabel holds a hash of the compose spec WITHOUT its proxy routes (and without the labels stamped here). A node compares the label on its running containers with the hash of an incoming spec to tell a routes-only version bump — which it applies without touching containers — from a real change.
const DeploymentVersionLabel = "cosmos-deployment-version"
DeploymentVersionLabel is the docker label key holding the integer spec version a container was created from (Deployment.Version, stringified). The scheduler compares the value a node reports against the desired version to decide whether a node is running a stale spec and needs a rolling re-apply.
Variables ¶
var DebouncedNetworkCleanUp = _debounceNetworkCleanUp()
var DockerClient *client.Client
var DockerContext context.Context
var DockerIsConnected atomic.Bool
race fix: atomic flag + a mutex serializing Connect (concurrent heartbeat goroutines raced on this flag and on the DockerClient pointer writes below)
var DockerNetworkLock = make(chan bool, 1)
use a semaphore lock
var DockerNetworkName = "cosmos-network"
var ErrLazyStarting = errors.New("lazy container is starting")
ErrLazyStarting is returned when the wait budget elapsed before the container became ready.
var ExportError = ""
var ImagePullAuthProvider func(registryHost string) (username, password string)
ImagePullAuthProvider, when set, supplies credentials for a registry host the node has no docker login for — the cluster's own registries, whose deploy tokens live in the constellation KV rather than in ~/.docker. Returns empty strings when it has none for the host.
Functions ¶
func AddLabels ¶
func AddLabels(containerConfig types.ContainerJSON, labels map[string]string) error
func ApplyComposeRoutes ¶ added in v0.24.0
func ApplyComposeRoutes(spec DockerServiceCreateRequest) bool
ApplyComposeRoutes materializes a compose's routes into this node's config without touching any container: the routes-only apply path. Same lock and restart discipline as utils.ApplyManagedRoutes.
func AttachNetwork ¶
func AttachNetwork(w http.ResponseWriter, req *http.Request)
AttachNetwork godoc @Summary Attach a Docker network to a container @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param networkId path string true "Network ID" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/network/{networkId} [post]
func AttachNetworkToCosmos ¶
func AutoUpdateContainerRoute ¶
func AutoUpdateContainerRoute(w http.ResponseWriter, req *http.Request)
AutoUpdateContainerRoute godoc @Summary Enable or disable auto-update for a Docker container @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param status path string true "Auto-update status (true or false)" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/auto-update/{status} [get]
func BootstrapAllContainersFromTags ¶
func BootstrapAllContainersFromTags() []error
func CanUpdateImageRoute ¶
func CanUpdateImageRoute(w http.ResponseWriter, req *http.Request)
CanUpdateImageRoute godoc @Summary Check whether a container's image has a newer version available @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/check-update [get]
func CheckDockerNetworkMode ¶ added in v0.14.0
func CheckDockerNetworkMode() string
func CheckPorts ¶
func CheckPorts() error
func CheckUpdatesAvailable ¶
func CleanupExitedDeploymentContainers ¶ added in v0.23.0
func CleanupExitedDeploymentContainers()
func ComposeRoutes ¶ added in v0.24.0
func ComposeRoutes(spec DockerServiceCreateRequest) []utils.ProxyRouteConfig
ComposeRoutes lists every route the compose carries, service by service.
func ComposeRoutesAtVersion ¶ added in v0.24.0
func ComposeRoutesAtVersion(spec DockerServiceCreateRequest, version int) bool
ComposeRoutesAtVersion reports whether every route the compose carries is present in this node's config, owned, and rendered from at least the given version — i.e. whether a routes-only apply of that version already landed. A compose without routes can never be "at version" this way; the container label is the only witness then.
func ComposeSpecHash ¶ added in v0.24.0
func ComposeSpecHash(spec DockerServiceCreateRequest) string
ComposeSpecHash hashes everything about a compose that requires a container (re)create: services minus their routes, plus networks and volumes, with the scheduler's own labels stripped. Map keys are sorted by encoding/json, so the hash is stable across marshal orders.
func ConnectToNetworkIfNotConnected ¶
func ConnectToNetworkIfNotConnected(containerConfig types.ContainerJSON, networkName string) error
func ConnectToNetworkSync ¶
func ConnectToSecureNetwork ¶
func ConnectToSecureNetwork(containerConfig types.ContainerJSON) (bool, error)
func ContainerIDsByDeploymentLabel ¶ added in v0.22.11
ContainerIDsByDeploymentLabel returns the container IDs currently labeled cosmos-deployment=<name>. Used by the scheduler's waitForRunning to poll container state after an apply.
func ContainerIsRunning ¶ added in v0.22.11
func ContainersIdRoute ¶
func ContainersIdRoute(w http.ResponseWriter, req *http.Request)
func ContainersRoute ¶
func ContainersRoute(w http.ResponseWriter, req *http.Request)
func CreateCosmosNetwork ¶
func CreateLinkNetwork ¶
func CreateNetworkRoute ¶
func CreateNetworkRoute(w http.ResponseWriter, req *http.Request)
CreateNetworkRoute godoc @Summary Create a new Docker network @Tags docker @Accept json @Produce json @Param body body createNetworkPayload true "Network creation payload" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/networks [post]
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)
CreateServiceRoute godoc @Summary Create a Docker service (compose-like) with networks, volumes, and containers @Tags docker @Accept json @Produce plain @Param body body DockerServiceCreateRequest true "Service creation payload" @Security BearerAuth @Success 200 {string} string "Streamed creation output" @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/docker-service [post]
func CreateVolumeRoute ¶
func CreateVolumeRoute(w http.ResponseWriter, req *http.Request)
CreateVolumeRoute godoc @Summary Create a new Docker volume @Tags docker @Accept json @Produce json @Param body body VolumeCreateRequest true "Volume creation payload" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/volumes [post]
func DebouncedExportDocker ¶ added in v0.11.0
func DebouncedExportDocker()
func DeleteNetworkRoute ¶
func DeleteNetworkRoute(w http.ResponseWriter, req *http.Request)
DeleteNetworkRoute godoc @Summary Delete a Docker network by ID @Tags docker @Produce json @Param networkID path string true "Network ID" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/network/{networkID} [delete]
func DeleteVolumeRoute ¶
func DeleteVolumeRoute(w http.ResponseWriter, req *http.Request)
DeleteVolumeRoute godoc @Summary Delete a Docker volume by name @Tags docker @Produce json @Param volumeName path string true "Name of the volume to delete" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/volume/{volumeName} [delete]
func DeploymentRoutesLabelEntries ¶ added in v0.24.0
func DeploymentRoutesLabelEntries(spec DockerServiceCreateRequest) []string
DeploymentRoutesLabelEntries renders the routes label for a compose: one "kind:name" owner pair per distinct owner. Teardown withdraws by owner, so the label survives a rename of the route inside the compose.
func DeploymentRunningAtSpecHash ¶ added in v0.24.0
DeploymentRunningAtSpecHash reports whether every named container is alive with this deployment's label and the given spec hash.
func DeploymentRunningAtVersion ¶ added in v0.24.0
DeploymentRunningAtVersion reports whether every named container is alive with this deployment's label at exactly the given spec version.
func DetachNetwork ¶
func DetachNetwork(w http.ResponseWriter, req *http.Request)
DetachNetwork godoc @Summary Detach a Docker network from a container @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param networkId path string true "Network ID" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/network/{networkId} [delete]
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 EditContainer ¶
func EffectiveDeploymentVersion ¶ added in v0.24.0
func EffectiveDeploymentVersion(routes []utils.ProxyRouteConfig, labelVersion int, owners []string) int
EffectiveDeploymentVersion lifts a container-label version to the version a routes-only apply brought this node to. Labels are immutable, so the witness is the ManagedByVersion stamped on the routes owned by the pairs recorded in the deployment's routes label: when every owner has routes in config and the lowest version among them is newer than the label, the routes-only apply landed at that version. Read from config, so it survives a restart. `owners` empty (no routes label) means the label is the truth.
func EnsureLazyAwake ¶ added in v0.24.0
EnsureLazyAwake wakes a dormant lazy container before the proxy dials it; maxWait <= 0 waits for the full wake.
func ExportContainerRoute ¶ added in v0.14.0
func ExportContainerRoute(w http.ResponseWriter, req *http.Request)
ExportContainerRoute godoc @Summary Export a container configuration as a service definition @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/export [get]
func ExportDocker ¶ added in v0.11.0
func ExportDocker()
func ForgetContainerIP ¶ added in v0.24.0
func ForgetContainerIP(containerName string)
ForgetContainerIP drops the cached IP of a container.
func ForgetLocalNetworkSubnets ¶ added in v0.24.0
func ForgetLocalNetworkSubnets()
ForgetLocalNetworkSubnets expires the cache (called from the docker event loop); the stale list keeps answering until the next lookup triggers a refresh.
func GetAllPorts ¶
func GetAllPorts(container types.ContainerJSON) []string
func GetContainerIPByName ¶ added in v0.12.0
func GetContainerLogsRoute ¶
func GetContainerLogsRoute(w http.ResponseWriter, req *http.Request)
GetContainerLogsRoute godoc @Summary Retrieve logs for a Docker container @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param limit query int false "Maximum number of log lines to return" @Param search query string false "Filter logs by search string" @Param lastReceivedLogs query string false "Timestamp to fetch logs until" @Param errorOnly query bool false "Return only stderr logs" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/logs [get]
func GetContainerRoute ¶
func GetContainerRoute(w http.ResponseWriter, req *http.Request)
GetContainerRoute godoc @Summary Inspect a single Docker container by ID @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/ [get]
func GetContainersUsingPath ¶ added in v0.18.0
GetContainersUsingPath returns a list of container IDs that have volumes or binds that are either equal to or contained within the specified path
func HasAutoUpdateOn ¶
func HasAutoUpdateOn(containerConfig types.ContainerJSON) 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)
InspectImageRoute godoc @Summary Inspect a Docker image by name @Tags docker @Produce json @Param imageName query string true "Name of the Docker image to inspect" @Security BearerAuth @Success 200 {object} types.ImageInspect @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/images [get]
func IsConnectedToASecureCosmosNetwork ¶
func IsConnectedToASecureCosmosNetwork(self types.ContainerJSON, containerConfig types.ContainerJSON) (bool, error, bool)
func IsConnectedToNetwork ¶
func IsConnectedToNetwork(containerConfig types.ContainerJSON, networkName string) bool
func IsInsideContainer ¶ added in v0.16.0
func IsInsideContainer()
func IsLazyLabels ¶ added in v0.24.0
func IsLocalDockerIP ¶ added in v0.24.0
IsLocalDockerIP reports whether ip sits on a network of this docker host; wired into utils.IsLocalDockerIP at startup.
func LazyConnClose ¶ added in v0.24.0
func LazyConnClose(containerName string)
func LazyConnOpen ¶ added in v0.24.0
func LazyConnOpen(containerName string)
func LazyContainerRoute ¶ added in v0.24.0
func LazyContainerRoute(w http.ResponseWriter, req *http.Request)
LazyContainerRoute godoc @Summary Enable or disable lazy start (stop when idle) for a Docker container @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param status path string true "Lazy status (true or false)" @Param idle query string false "Idle duration before the container is stopped (Go duration, ex 1h)" @Param startTimeout query string false "Readiness timeout after a wake (Go duration, ex 60s)" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/lazy/{status} [get]
func LazyIsDormant ¶ added in v0.24.0
LazyIsDormant reports whether the container is lazy and currently stopped.
func ListContainerNetworks ¶
func ListContainerNetworks(w http.ResponseWriter, req *http.Request)
ListContainerNetworks godoc @Summary List all networks and the networks a container is connected to @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/networks [get]
func ListContainers ¶
func ListContainersRoute ¶
func ListContainersRoute(w http.ResponseWriter, req *http.Request)
ListContainersRoute godoc @Summary List all Docker containers @Tags docker @Produce json @Param limit query int false "Maximum number of containers to return" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps [get]
func ListDeploymentNamesRunningHere ¶ added in v0.22.11
func ListDeploymentVersionsRunningHere ¶ added in v0.22.19
ListDeploymentVersionsRunningHere returns, per deployment with at least one running container on this host
func ListNetworksRoute ¶
func ListNetworksRoute(w http.ResponseWriter, req *http.Request)
ListNetworksRoute godoc @Summary List all Docker networks @Tags docker @Produce json @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/networks [get]
func ListVolumeRoute ¶
func ListVolumeRoute(w http.ResponseWriter, req *http.Request)
ListVolumeRoute godoc @Summary List all Docker volumes @Tags docker @Produce json @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/volumes [get]
func ManageContainerRoute ¶
func ManageContainerRoute(w http.ResponseWriter, req *http.Request)
ManageContainerRoute godoc @Summary Perform a management action on a Docker container @Description Actions: stop, start, restart, kill, remove, pause, unpause, recreate, update @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param action path string true "Management action" Enums(stop, start, restart, kill, remove, pause, unpause, recreate, update) @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/manage/{action} [get]
func MergeComposeRoutes ¶ added in v0.24.0
func MergeComposeRoutes(routes []utils.ProxyRouteConfig, spec DockerServiceCreateRequest, onLog func(string)) ([]utils.ProxyRouteConfig, bool)
MergeComposeRoutes folds the compose's routes into a route list. Routes stamped with an owner go through the owner merge (prune + upsert per owner pair); unstamped routes — a compose applied from the ServApps UI — keep the historical upsert-by-name so a user route imported with a stack stays a plain user route. Returns the merged list and whether it changed.
func MigrateToHostModeRoute ¶ added in v0.14.0
func MigrateToHostModeRoute(w http.ResponseWriter, req *http.Request)
MigrateToHostModeRoute godoc @Summary Migrate Cosmos container to host network mode @Tags docker @Accept json @Produce json @Param body body migrateToHostMode true "HTTP and HTTPS port configuration" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/migrate-host [post]
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)
PullImage godoc @Summary Pull a Docker image from a registry @Tags docker @Produce plain @Param imageName query string true "Name of the Docker image to pull" @Security BearerAuth @Success 200 {string} string "Streamed pull output" @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/images/pull [get]
func PullImageIfMissing ¶
func PullImageIfMissing(w http.ResponseWriter, req *http.Request)
PullImageIfMissing godoc @Summary Pull a Docker image only if it is not already present locally @Tags docker @Produce plain @Param imageName query string true "Name of the Docker image to pull" @Security BearerAuth @Success 200 {string} string "Streamed pull output" @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/images/pull-if-missing [get]
func RecreateContainer ¶
func RecreateContainer(containerID string, containerConfig types.ContainerJSON) (string, error)
func RecreateDepedencies ¶
func RecreateDepedencies(containerID, containerName string)
func RemoveByDeploymentLabel ¶ added in v0.22.11
RemoveByDeploymentLabel discovers and tears down every container, network, and (unless keepVolumes is set) volume labeled cosmos-deployment=<deploymentName>. Mirrors the sequence the servapps delete modal uses (containers → 1s pause → networks + volumes in parallel). Per-resource failures are collected, not fatal — partial teardown is still progress.
keepVolumes skips the volume teardown: used by the scheduler's re-apply path when a deployment's spec version changed, so the new containers reattach to the existing volumes and persistent data survives the update. A full delete (ActionRemove) passes keepVolumes=false.
func RemoveDeploymentRoutes ¶ added in v0.24.0
RemoveDeploymentRoutes withdraws the routes recorded on a deployment's containers. Entries are owner pairs ("kind:name"); anything else is ignored. Missing routes are not errors — a retried remove must be able to finish.
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 RouteNamesByDeploymentLabel ¶ added in v0.24.0
RouteNamesByDeploymentLabel returns the distinct DeploymentRoutesLabel owner pairs on the deployment's containers; call BEFORE teardown.
func SecureContainerRoute ¶
func SecureContainerRoute(w http.ResponseWriter, req *http.Request)
SecureContainerRoute godoc @Summary Set or unset network isolation on a Docker container @Tags docker @Produce json @Param containerId path string true "Container ID or name" @Param status path string true "Network secured status (true or false)" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/secure/{status} [get]
func SelfAction ¶ added in v0.14.0
func SelfRecreate ¶
func SelfRecreate() error
func StartContainers ¶ added in v0.18.0
StartContainers starts the given containers and waits for them to be running
func StartLazyReaper ¶ added in v0.24.0
func StartLazyReaper()
StartLazyReaper seeds the activity table and starts the idle ticker. Idempotent.
func StopContainer ¶ added in v0.12.0
func StopContainer(containerName string)
func StopContainers ¶ added in v0.18.0
StopContainers stops the given containers and waits for them to stop
func StopLazyReaper ¶ added in v0.24.0
func StopLazyReaper()
func TerminalRoute ¶
func TerminalRoute(w http.ResponseWriter, r *http.Request)
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)
UpdateContainerRoute godoc @Summary Update a Docker container's settings @Tags docker @Accept json @Produce json @Param containerId path string true "Container ID or name" @Param body body ContainerForm true "Container update payload" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/servapps/{containerId}/update [post]
func UpdatePorts ¶
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" validate:"required"`
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 map[string]ContainerCreateRequestContainerDependsOnCont `json:"depends_on,omitempty"`
Tty bool `json:"tty,omitempty"`
StdinOpen bool `json:"stdin_open,omitempty"`
Command string `json:"command,omitempty"`
Entrypoint string `json:"entrypoint,omitempty"`
Runtime string `json:"runtime,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"`
// Resource constraints
MemLimit string `json:"mem_limit,omitempty"`
MemReservation string `json:"mem_reservation,omitempty"`
CPUs float64 `json:"cpus,omitempty"`
CpusetCpus string `json:"cpuset_cpus,omitempty"`
PostInstall []string `json:"post_install,omitempty"`
}
func ExportContainer ¶ added in v0.14.0
func ExportContainer(containerID string) (ContainerCreateRequestContainer, error)
func ReOrderServices ¶
func ReOrderServices(serviceMap map[string]ContainerCreateRequestContainer) ([]ContainerCreateRequestContainer, bool, error)
type ContainerCreateRequestContainerDependsOnCont ¶ added in v0.16.0
type ContainerCreateRequestContainerHealthcheck ¶ added in v0.11.0
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 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"`
// DNS replaces the DNS servers of the container when sent, an empty list for the default of Docker
DNS []string `json:"dns"`
MemLimit string `json:"memLimit"`
CPUs float64 `json:"cpus"`
}
type ContainerLiveness ¶ added in v0.24.0
type ContainerLiveness struct {
// Exists is false when docker has no such container (a definite answer, unlike an error).
Exists bool
// Running is true only for state "running".
Running bool
// Uptime is how long the CURRENT run has lasted. Zero unless Running.
Uptime time.Duration
}
ContainerLiveness is a point-in-time snapshot of whether a container is up and how long the current run has lasted.
func GetContainerLiveness ¶ added in v0.24.0
func GetContainerLiveness(containerName string) (ContainerLiveness, error)
GetContainerLiveness reports a container's live state, uncached; a missing container is (Exists: false, nil), not an error.
type ContainerStats ¶ added in v0.12.0
type ContainerStats struct {
Name string
CPUUsage float64
MemUsage uint64
MemLimit uint64
NetworkRx float64
NetworkTx float64
}
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"`
}
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 ParseDockerLogHeader ¶
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 ¶
Source Files
¶
- api.go
- api_autoupdate.go
- api_blueprint.go
- api_containers.go
- api_getcontainers.go
- api_getlogs.go
- api_images.go
- api_lazy.go
- api_managecont.go
- api_migrate.go
- api_networks.go
- api_secureContainer.go
- api_terminal.go
- api_update.go
- api_updateContainer.go
- api_volumes.go
- backups.go
- bootstrap.go
- checkPorts.go
- deployment_routes.go
- docker.go
- events.go
- export.go
- ip.go
- lazy.go
- liveness.go
- local_networks.go
- network.go
- remove_service.go