Documentation
¶
Overview ¶
Package docker provide abstaraction to pull/start/stop/remove docker image. Package uses docker-cli from running host.
Index ¶
- Constants
- Variables
- func CreateImageName(repoPath, tag string) string
- func CreateImageNameFromInputInfo(di *api.DutInput_DockerImage, defaultRepoPath, defaultTag string) string
- func CreateNetwork(ctx context.Context, name string) error
- func GCloudToken(ctx context.Context, keyfile string, forceNewAuth bool) (string, error)
- func RemoveNetwork(ctx context.Context, name string) error
- type Docker
Constants ¶
View Source
const ( // Default fallback docket tag. DefaultImageTag = "stable" RETRYNUM = 2 )
Variables ¶
View Source
var ( LogPullTime = logPullTime LogRunTime = logRunTime LogStatus = logStatus LogPullTimeProd = logPullTimeProd LogRunTimeProd = logRunTimeProd LogStatusProd = logStatusProd )
Export metrics API.
Functions ¶
func CreateImageName ¶
CreateImageName creates docker image name from repo-path and tag.
func CreateImageNameFromInputInfo ¶
func CreateImageNameFromInputInfo(di *api.DutInput_DockerImage, defaultRepoPath, defaultTag string) string
CreateImageNameFromInputInfo creates docker image name from input info.
If info is empty then return empty name. If one of the fields empty then use related default value.
func CreateNetwork ¶
CreateNetwork created network for docker.
func GCloudToken ¶
GCloudToken will try to return the gcloud token for `docker login`.
Types ¶
type Docker ¶
type Docker struct { // Requested docker image, if not exist then use FallbackImageName. RequestedImageName string // Registry to auth for docker interactions. Registry string // token to token TokenFile string // Fall back docker image name. Used if RequestedImageName is empty or image not found. FallbackImageName string // ServicePort tells which port need to bing bind from docker to the host. // Bind is always to the first free port. ServicePort int // Run container in detach mode. Detach bool // Name to be assigned to the container - should be unique. Name string // ExecCommand tells if we need run special command when we start container. ExecCommand []string // Attach volumes to the docker image. Volumes []string // PortMappings is a list of "host port:docker port" or "docker port" to publish. PortMappings []string // Network used for running container. Network string // LogFileDir used for the logfile for the service in the container. LogFileDir string Stdoutbuf *bytes.Buffer Stderrbuf *bytes.Buffer PullExitCode int Started bool // contains filtered or unexported fields }
Docker holds data to perform the docker manipulations.
func (*Docker) MatchingHostPort ¶
HostPort returns the port which the given docker port maps to.
Click to show internal directories.
Click to hide internal directories.