Skip to content

Instantly share code, notes, and snippets.

@ChristianKniep
Last active April 20, 2020 18:20
Show Gist options
  • Save ChristianKniep/2b13b0a01ebd99a82e0b7ffb2710c624 to your computer and use it in GitHub Desktop.
Save ChristianKniep/2b13b0a01ebd99a82e0b7ffb2710c624 to your computer and use it in GitHub Desktop.

Revisions

  1. ChristianKniep revised this gist Jun 9, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ func main() {
    for _, c := range containers {
    body, _ := cli.ContainerStats(context.Background(), c.ID, false)
    defer body.Close()
    content, _ := ioutil.ReadAll(body)
    content, _ := ioutil.ReadAll(body)
    fmt.Printf(string(content))
    }
    }
  2. ChristianKniep created this gist Jun 9, 2016.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    package main

    import (
    "fmt"
    "io/ioutil"

    "github.com/docker/engine-api/client"
    "github.com/docker/engine-api/types"
    "golang.org/x/net/context"
    )

    func main() {

    cli, err := client.NewEnvClient()
    if err != nil {
    panic(err)
    }

    options := types.ContainerListOptions{All: false}
    containers, err := cli.ContainerList(context.Background(), options)
    if err != nil {
    panic(err)
    }

    for _, c := range containers {
    body, _ := cli.ContainerStats(context.Background(), c.ID, false)
    defer body.Close()
    content, _ := ioutil.ReadAll(body)
    fmt.Printf(string(content))
    }
    }