MCPcopy
hub / github.com/dgraph-io/dgraph / DockerRun

Function DockerRun

testutil/docker.go:237–260  ·  view source on GitHub ↗

DockerRun performs the specified operation on the given container instance.

(instance string, op int)

Source from the content-addressed store, hash-verified

235
236// DockerRun performs the specified operation on the given container instance.
237func DockerRun(instance string, op int) error {
238 c := getContainer(instance)
239 if c.ID == "" {
240 glog.Fatalf("Unable to find container: %s\n", instance)
241 return nil
242 }
243
244 cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
245 x.Check(err)
246
247 switch op {
248 case Start:
249 if err := cli.ContainerStart(context.Background(), c.ID, container.StartOptions{}); err != nil {
250 return err
251 }
252 case Stop:
253 dur := 30
254 o := container.StopOptions{Timeout: &dur}
255 return cli.ContainerStop(context.Background(), c.ID, o)
256 default:
257 x.Fatalf("Wrong Docker op: %v\n", op)
258 }
259 return nil
260}
261
262// MARKED FOR DEPRECATION: DockerCp copies from/to a container. Paths inside a container have the format
263// container_name:path.

Callers 2

TestZeroGracefulShutdownFunction · 0.92
TestSnapshotFunction · 0.92

Calls 4

CheckFunction · 0.92
FatalfFunction · 0.92
getContainerFunction · 0.85
FatalfMethod · 0.80

Tested by 2

TestZeroGracefulShutdownFunction · 0.74
TestSnapshotFunction · 0.74