code-intelligence.com/cifuzz@v0.40.0/internal/container/client.go (about) 1 package container 2 3 import ( 4 "github.com/docker/docker/client" 5 "github.com/pkg/errors" 6 ) 7 8 var dockerClient *client.Client 9 10 // getDockerClient returns a docker client and will also handle its closing. It will take configuration options in the future. 11 func getDockerClient() (*client.Client, error) { 12 if dockerClient != nil { 13 return dockerClient, nil 14 } 15 dockerClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) 16 if err != nil { 17 return nil, errors.WithStack(err) 18 } 19 defer dockerClient.Close() 20 return dockerClient, nil 21 }