func (n *ContainerName) FindOrCreate(image string, args ...string) (*Container, error) { n.mu.Lock() c, err := Find(n.Name) if err != nil { c, err = Create(n.Name, image, args) } n.mu.Unlock() if err != nil { return nil, err } if err := util.AwaitReachable(c.anyAddr(), 30*time.Second); err != nil { //c.Close() return nil, err } return c, nil }
func New(args ...string) (*Container, error) { if err := initDocker(); err != nil { return nil, err } id, err := dockerRun(args) if err != nil { return nil, err } c, err := newContainer(id) if err != nil { return nil, err } if err := util.AwaitReachable(c.anyAddr(), 30*time.Second); err != nil { c.Close() return nil, err } return c, nil }