39 lines
748 B
Go
39 lines
748 B
Go
package cmii_operator
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/docker/docker/api/types/filters"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/client"
|
|
)
|
|
|
|
func GetAllContainer() {
|
|
apiClient, err := client.NewClientWithOpts(client.FromEnv)
|
|
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer apiClient.Close()
|
|
|
|
containers, err := apiClient.ContainerList(context.Background(), types.ContainerListOptions{
|
|
Quiet: false,
|
|
Size: false,
|
|
All: true,
|
|
Latest: false,
|
|
Since: "",
|
|
Before: "",
|
|
Limit: 0,
|
|
Filters: filters.Args{},
|
|
})
|
|
if err != nil {
|
|
log.ErrorF("[GetAllContainer] - error => %s", err.Error())
|
|
}
|
|
|
|
for _, ctr := range containers {
|
|
fmt.Printf("%s %s (status: %s)\n", ctr.ID, ctr.Image, ctr.Status)
|
|
}
|
|
|
|
}
|