29 lines
556 B
Go
29 lines
556 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
docker_client "github.com/docker/docker/client"
|
|
)
|
|
|
|
// Docker client
|
|
var Docker = newClient("tcp://server.yumc.pw:2376", "1.38")
|
|
|
|
type docker struct {
|
|
client *docker_client.Client
|
|
context context.Context
|
|
}
|
|
|
|
//Init the Docker Client
|
|
func newClient(host string, version string) *docker {
|
|
client, err := docker_client.NewClient(host, version, nil, nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &docker{client: client, context: context.TODO()}
|
|
}
|
|
|
|
func (d *docker) Version() string {
|
|
return d.client.ClientVersion()
|
|
}
|