From 91dea3b5b2a2f1dd0da755cff3323eabae7780b8 Mon Sep 17 00:00:00 2001 From: karimra Date: Fri, 4 Sep 2020 12:10:20 +0800 Subject: [PATCH] change docker client package --- clab/clab.go | 4 +++- clab/docker.go | 25 +++++++++++-------------- go.mod | 2 ++ go.sum | 3 +++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/clab/clab.go b/clab/clab.go index 0faeb9eca..452521af7 100644 --- a/clab/clab.go +++ b/clab/clab.go @@ -1,6 +1,8 @@ package clab -import "docker.io/go-docker" +import ( + docker "github.com/docker/engine/client" +) var debug bool diff --git a/clab/docker.go b/clab/docker.go index 21a1e3639..e0ef98e29 100644 --- a/clab/docker.go +++ b/clab/docker.go @@ -7,9 +7,9 @@ import ( "strings" "time" - "docker.io/go-docker/api/types" - "docker.io/go-docker/api/types/container" - "docker.io/go-docker/api/types/network" + "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" log "github.com/sirupsen/logrus" ) @@ -51,13 +51,13 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) { networkOptions := types.NetworkCreate{ CheckDuplicate: true, Driver: "bridge", - Scope: "local", - EnableIPv6: true, - IPAM: ipam, - Internal: false, - Attachable: false, - Ingress: false, - ConfigOnly: false, + //Scope: "local", + EnableIPv6: true, + IPAM: ipam, + Internal: false, + Attachable: false, + //Ingress: false, + //ConfigOnly: false, } var bridgeName string @@ -70,7 +70,7 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) { log.Debugf("Container network %s already exists", c.Conf.DockerInfo.Bridge) nctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() - netResource, err := c.DockerClient.NetworkInspect(nctx, c.Conf.DockerInfo.Bridge, types.NetworkInspectOptions{}) + netResource, err := c.DockerClient.NetworkInspect(nctx, c.Conf.DockerInfo.Bridge) //, types.NetworkInspectOptions{}) if err != nil { return err } @@ -124,7 +124,6 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) { return nil } - // DeleteBridge deletes a docker bridge func (c *cLab) DeleteBridge(ctx context.Context) (err error) { nctx, cancel := context.WithTimeout(ctx, 10*time.Second) @@ -187,7 +186,6 @@ func (c *cLab) CreateContainer(ctx context.Context, name string, node *Node) (er return c.InspectContainer(ctx, node.LongName, node) } - // StartContainer starts a docker container func (c *cLab) StartContainer(ctx context.Context, name string, node *Node) (err error) { log.Debug("Start container: ", name) @@ -235,7 +233,6 @@ func (c *cLab) DeleteContainer(ctx context.Context, name string, node *Node) (er return nil } - // InspectContainer inspects a docker container func (c *cLab) InspectContainer(ctx context.Context, id string, node *Node) (err error) { nctx, cancel := context.WithTimeout(ctx, 10*time.Second) diff --git a/go.mod b/go.mod index 3f04cdf36..06c2c9987 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,8 @@ require ( github.com/Microsoft/go-winio v0.4.14 // indirect github.com/awalterschulze/gographviz v2.0.1+incompatible github.com/docker/distribution v2.7.1+incompatible // indirect + github.com/docker/docker v1.13.1 + github.com/docker/engine v1.13.1 github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect github.com/gogo/protobuf v1.3.1 // indirect diff --git a/go.sum b/go.sum index ebdc03534..b02f0ac53 100644 --- a/go.sum +++ b/go.sum @@ -30,6 +30,9 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo= +github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/engine v1.13.1 h1:Cks33UT9YBW5Xyc3MtGDq2IPgqfJtJ+qkFaxc2b0Euc= +github.com/docker/engine v1.13.1/go.mod h1:3CPr2caMgTHxxIAZgEMd3uLYPDlRvPqCpyeRf6ncPcY= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=