Skip to content

Instantly share code, notes, and snippets.

@ChristianKniep
Created April 24, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristianKniep/fe18c2a0f8877da829b1523f304279f2 to your computer and use it in GitHub Desktop.
Save ChristianKniep/fe18c2a0f8877da829b1523f304279f2 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/docker/docker/client"
"github.com/docker/docker/api/types"
"golang.org/x/net/context"
"encoding/json"
"fmt"
)
const (
dockerHost = "unix:///var/run/docker.sock"
dockerAPI = "v1.29"
cID = "8e97d5bc9703"
)
func main() {
cli, _ := client.NewClient(dockerHost, dockerAPI, nil, nil)
cj, b, _ := cli.ContainerInspectWithRaw(context.Background(), cID, false)
fmt.Printf("cj.State: %v\n", cj.State)
var cnt types.Container
json.Unmarshal(cj, &cnt)
fmt.Printf("cnt.State: %v\n", cnt.State)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment