// New returns initialized docker plugin or error if failed to connect to docker deamon func New() (*docker, error) { dc, err := client.NewDockerClient() if err != nil { return nil, err } return &docker{ containers: map[string]containerData{}, client: dc, list: map[string]dock.APIContainers{}, }, nil }
// Docker plugin initializer func NewDocker() (*docker, error) { host, _ := os.Hostname() // create new docker client dockerClient := client.NewDockerClient() // list all running containers containers, err := dockerClient.ListContainers() if err != nil { return nil, err } d := &docker{ stats: cgroups.NewStats(), client: dockerClient, tools: new(tls.MyTools), containersInfo: containers, groupWrap: wrapper.Cgroups2Stats, hostname: host} return d, nil }