Created
December 29, 2022 11:41
-
-
Save veggiemonk/bb1faf361568597fd3ec251abbea6b34 to your computer and use it in GitHub Desktop.
simple docker client
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