MCPcopy Index your code
hub / github.com/coder/envbox / StopContainer

Function StopContainer

integration/integrationtest/docker.go:309–332  ·  view source on GitHub ↗
(t *testing.T, pool *dockertest.Pool, id string, to time.Duration)

Source from the content-addressed store, hash-verified

307}
308
309func StopContainer(t *testing.T, pool *dockertest.Pool, id string, to time.Duration) {
310 t.Helper()
311
312 err := pool.Client.KillContainer(docker.KillContainerOptions{
313 ID: id,
314 Signal: docker.SIGTERM,
315 })
316 require.NoError(t, err)
317
318 ctx, cancel := context.WithTimeout(context.Background(), to)
319 defer cancel()
320 for r := retry.New(time.Second, time.Second); r.Wait(ctx); {
321 cnt, err := pool.Client.InspectContainer(id)
322 require.NoError(t, err)
323
324 if cnt.State.Running {
325 continue
326 }
327
328 return
329 }
330
331 t.Fatalf("timed out waiting for container %s to stop", id)
332}
333
334// cmdLineEnvs returns args passed to the /envbox command
335// but using their env var alias.

Callers 1

TestDockerFunction · 0.92

Calls 1

WaitMethod · 0.45

Tested by 1

TestDockerFunction · 0.74