肥皂起泡泡
你可以使用 docker/clienthttps://godoc.org/github.com/docker/docker/client示例代码:# listcontainers.gopackage mainimport ( "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) }}然后像这样执行DOCKER_API_VERSION=1.35 go run listcontainers.go