func GetClient(c *C) *dockerclient.Client { client, err := docker.CreateClient(docker.ClientOpts{}) c.Assert(err, IsNil) return client }
func NewClientFactory(opts docker.ClientOpts) (docker.ClientFactory, error) { userOpts := opts systemOpts := opts userOpts.Host = config.DOCKER_HOST systemOpts.Host = config.DOCKER_SYSTEM_HOST userClient, err := docker.CreateClient(userOpts) if err != nil { return nil, err } systemClient, err := docker.CreateClient(systemOpts) if err != nil { return nil, err } return &ClientFactory{ userClient: userClient, systemClient: systemClient, }, nil }
func getPid(service string, project *project.Project) (int, error) { s, err := project.CreateService(service) if err != nil { return 0, err } containers, err := s.Containers() if err != nil { return 0, err } if len(containers) == 0 { return 0, nil } client, err := docker.CreateClient(docker.ClientOpts{ Host: config.DOCKER_SYSTEM_HOST, }) if err != nil { return 0, err } id, err := containers[0].Id() if err != nil { return 0, err } info, err := client.InspectContainer(id) if err != nil || info == nil { return 0, err } if info.State.Running { return info.State.Pid, nil } return 0, nil }