Skip to content

Instantly share code, notes, and snippets.

@hernandanielg
Created March 5, 2019 14:30
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 hernandanielg/786bf953cff14bfdf8dfb413e5bfcbf4 to your computer and use it in GitHub Desktop.
Save hernandanielg/786bf953cff14bfdf8dfb413e5bfcbf4 to your computer and use it in GitHub Desktop.
package main
import (
"context"
"fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
func main() {
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
panic(err)
}
containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
if err != nil {
panic(err)
}
for _, container := range containers {
fmt.Printf("%s %s\n", container.ID[:10], container.Image)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment