package main
import (
"fmt"
"log"
docker "github.com/fsouza/go-dockerclient"
)
func main() {
client, err := docker.NewClient("unix:///var/run/docker.sock")
if err != nil {
log.Fatal(err)
}
info, err := client.ListContainers(docker.ListContainersOptions{All: true})
if err != nil {
log.Fatal(err)
}
for _, co := range info {
dinfo, err := client.InspectContainer(co.ID[0:12])
if err != nil {
log.Fatal(err)
}
fmt.Println(dinfo.State.Pid)
}
}
列出容器的pid
最新推荐文章于 2024-08-21 14:55:01 发布