mirror of
https://github.com/crazy-max/diun.git
synced 2025-01-12 11:38:11 +00:00
25 lines
561 B
Go
25 lines
561 B
Go
package docker
|
|
|
|
import (
|
|
"sort"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/api/types/filters"
|
|
)
|
|
|
|
// ContainerList returns Docker containers
|
|
func (c *Client) ContainerList(filterArgs filters.Args) ([]types.Container, error) {
|
|
containers, err := c.API.ContainerList(c.ctx, container.ListOptions{
|
|
Filters: filterArgs,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
sort.Slice(containers, func(i, j int) bool {
|
|
return containers[i].Image < containers[j].Image
|
|
})
|
|
|
|
return containers, nil
|
|
}
|