MCPcopy
hub / github.com/google/cadvisor / Run

Method Run

integration/framework/framework.go:346–359  ·  view source on GitHub ↗

TODO(vmarmol): Use the Docker remote API. TODO(vmarmol): Refactor a set of "RunCommand" actions. Runs a Docker container in the background. Uses the specified DockerRunArgs and command. e.g.: RunDockerContainer(DockerRunArgs{Image: "busybox"}, "ping", "www.google.com") -> docker run busybox ping

(args DockerRunArgs, cmd ...string)

Source from the content-addressed store, hash-verified

344//
345// -> docker run busybox ping www.google.com
346func (a dockerActions) Run(args DockerRunArgs, cmd ...string) string {
347 dockerCommand := append(append([]string{"docker", "run", "-d"}, args.Args...), args.Image)
348 dockerCommand = append(dockerCommand, cmd...)
349 output, _ := a.fm.Shell().Run("sudo", dockerCommand...)
350
351 // The last line is the container ID.
352 elements := strings.Fields(output)
353 containerID := elements[len(elements)-1]
354
355 a.fm.cleanups = append(a.fm.cleanups, func() {
356 a.fm.Shell().Run("sudo", "docker", "rm", "-f", containerID)
357 })
358 return containerID
359}
360func (a dockerActions) Version() []string {
361 dockerCommand := []string{"docker", "version", "-f", "'{{.Server.Version}}'"}
362 output, _ := a.fm.Shell().Run("sudo", dockerCommand...)

Callers 2

RunPauseMethod · 0.95
RunBusyboxMethod · 0.95

Calls 2

RunMethod · 0.65
ShellMethod · 0.65

Tested by

no test coverage detected