MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / DockerCpFromContainer

Function DockerCpFromContainer

testutil/docker.go:270–287  ·  view source on GitHub ↗

DockerCpFromContainer copies from a container.

(containerID, srcPath, dstPath string)

Source from the content-addressed store, hash-verified

268
269// DockerCpFromContainer copies from a container.
270func DockerCpFromContainer(containerID, srcPath, dstPath string) error {
271 cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
272 x.Check(err)
273
274 tarStream, _, err := cli.CopyFromContainer(context.Background(), containerID, srcPath)
275 if err != nil {
276 fmt.Println(err)
277 return nil
278 }
279 tr := tar.NewReader(tarStream)
280 _, err = tr.Next()
281 x.Check(err)
282
283 data, err := io.ReadAll(tr)
284 x.Check(err)
285
286 return os.WriteFile(dstPath, data, 0644)
287}
288
289// DockerExec executes a command inside the given container.
290func DockerExec(instance string, cmd ...string) error {

Callers 1

stopClusterFunction · 0.92

Calls 2

CheckFunction · 0.92
NextMethod · 0.45

Tested by

no test coverage detected