MCPcopy
hub / github.com/moby/moby / ExampleClient_ContainerLogs

Function ExampleClient_ContainerLogs

client/container_logs_example_test.go:14–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func ExampleClient_ContainerLogs() {
15 apiClient, err := client.New(
16 client.FromEnv,
17 client.WithUserAgent("my-application/1.0.0"),
18 )
19 if err != nil {
20 log.Fatal(err)
21 }
22
23 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
24 defer cancel()
25 res, err := apiClient.ContainerLogs(ctx, "my_container_id", client.ContainerLogsOptions{
26 ShowStdout: true,
27 ShowStderr: true,
28 })
29 if err != nil {
30 log.Fatal(err)
31 }
32 defer res.Close()
33
34 _, err = io.Copy(os.Stdout, res)
35 if err != nil && !errors.Is(err, io.EOF) {
36 log.Fatal(err)
37 }
38}

Callers

nothing calls this directly

Calls 6

WithTimeoutMethod · 0.80
NewMethod · 0.65
ContainerLogsMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…