mirror of
https://github.com/crazy-max/diun.git
synced 2025-04-14 15:18:32 +00:00
Simple Docker client impl
This commit is contained in:
parent
d407bce8fb
commit
bfa446fe00
1 changed files with 27 additions and 0 deletions
27
pkg/docker/client.go
Normal file
27
pkg/docker/client.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package _dev
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
// Client represents an active docker object
|
||||
type Client struct {
|
||||
Cli *client.Client
|
||||
}
|
||||
|
||||
// NewEnvClient initializes a new Docker API client based on environment variables
|
||||
func NewEnvClient() (*Client, error) {
|
||||
d, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("1.12"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, err = d.ServerVersion(context.Background())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{Cli: d}, err
|
||||
}
|
Loading…
Add table
Reference in a new issue