3
0
mirror of https://kolaente.dev/konrad/docker-db-backup.git synced 2026-01-10 02:50:08 +01:00

Add methods to get containers

This commit is contained in:
kolaente
2021-08-18 20:09:45 +02:00
parent 07b38fae0b
commit f7ef42b932
4 changed files with 990 additions and 0 deletions

15
client.go Normal file
View File

@@ -0,0 +1,15 @@
package main
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
)
func getClient() (*client.Client, error) {
return client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
}
func getContainers(c *client.Client) ([]types.Container, error) {
return c.ContainerList(context.Background(), types.ContainerListOptions{All: true})
}