Created
March 5, 2019 14:30
-
-
Save hernandanielg/786bf953cff14bfdf8dfb413e5bfcbf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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