MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / containerFromPull

Function containerFromPull

internal/test/docker.go:77–102  ·  view source on GitHub ↗

containerFromBuild starts a container from an image pulled from a registry - image specifies the image tag to pull. - cmd specifies the command line in execv format if any. - env specifies the environment variables in the VAR=VALUE format. - ports specifies the port mappings. The key is the contain

(
	t *testing.T,
	image string,
	cmd []string,
	env []string,
	ports map[string]string,
)

Source from the content-addressed store, hash-verified

75// - ports specifies the port mappings. The key is the container port, the value is the host port.
76// If the host port is left empty it is automatically mapped and can be retrieved later.
77func containerFromPull(
78 t *testing.T,
79 image string,
80 cmd []string,
81 env []string,
82 ports map[string]string,
83) container {
84 t.Helper()
85 t.Logf("Creating and starting a container from %s...", image)
86 cnt := &dockerContainer{
87 client: dockerClient(t),
88 image: image,
89 t: t,
90 cmd: cmd,
91 env: env,
92 ports: ports,
93 }
94
95 cnt.pull()
96 cnt.create()
97 t.Cleanup(cnt.remove)
98 cnt.start()
99 cnt.inspect()
100
101 return cnt
102}
103
104type container interface {
105 // id returns the container ID of the container.

Callers 1

S3Function · 0.85

Calls 7

pullMethod · 0.95
createMethod · 0.95
startMethod · 0.95
inspectMethod · 0.95
CleanupMethod · 0.80
dockerClientFunction · 0.70
LogfMethod · 0.65

Tested by

no test coverage detected