зеркало из https://github.com/microsoft/docker.git
Merge pull request #19249 from calavera/carry_17414
[Carry 17414] Added additional container information to "docker info".
This commit is contained in:
Коммит
a79f96828f
|
@ -25,6 +25,9 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
|||
}
|
||||
|
||||
fmt.Fprintf(cli.out, "Containers: %d\n", info.Containers)
|
||||
fmt.Fprintf(cli.out, " Running: %d\n", info.ContainersRunning)
|
||||
fmt.Fprintf(cli.out, " Paused: %d\n", info.ContainersPaused)
|
||||
fmt.Fprintf(cli.out, " Stopped: %d\n", info.ContainersStopped)
|
||||
fmt.Fprintf(cli.out, "Images: %d\n", info.Images)
|
||||
ioutils.FprintfIfNotEmpty(cli.out, "Server Version: %s\n", info.ServerVersion)
|
||||
ioutils.FprintfIfNotEmpty(cli.out, "Storage Driver: %s\n", info.Driver)
|
||||
|
|
|
@ -54,9 +54,24 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
|||
initPath := utils.DockerInitPath("")
|
||||
sysInfo := sysinfo.New(true)
|
||||
|
||||
var cRunning, cPaused, cStopped int
|
||||
for _, c := range daemon.List() {
|
||||
switch c.StateString() {
|
||||
case "paused":
|
||||
cPaused++
|
||||
case "running":
|
||||
cRunning++
|
||||
default:
|
||||
cStopped++
|
||||
}
|
||||
}
|
||||
|
||||
v := &types.Info{
|
||||
ID: daemon.ID,
|
||||
Containers: len(daemon.List()),
|
||||
ContainersRunning: cRunning,
|
||||
ContainersPaused: cPaused,
|
||||
ContainersStopped: cStopped,
|
||||
Images: len(daemon.imageStore.Map()),
|
||||
Driver: daemon.GraphDriverName(),
|
||||
DriverStatus: daemon.layerStore.DriverStatus(),
|
||||
|
|
|
@ -113,6 +113,7 @@ This section lists each version from latest to oldest. Each listing includes a
|
|||
* `GET /networks` now supports filtering by `name`, `id` and `type`.
|
||||
* `POST /containers/create` now allows you to set the static IPv4 and/or IPv6 address for the container.
|
||||
* `POST /networks/(id)/connect` now allows you to set the static IPv4 and/or IPv6 address for the container.
|
||||
* `GET /info` now includes the number of containers running, stopped, and paused.
|
||||
|
||||
### v1.21 API changes
|
||||
|
||||
|
|
|
@ -2081,6 +2081,9 @@ Display system-wide information
|
|||
{
|
||||
"Architecture": "x86_64",
|
||||
"Containers": 11,
|
||||
"ContainersRunning": 7,
|
||||
"ContainersStopped": 3,
|
||||
"ContainersPaused": 1,
|
||||
"CpuCfsPeriod": true,
|
||||
"CpuCfsQuota": true,
|
||||
"Debug": false,
|
||||
|
|
|
@ -21,6 +21,9 @@ For example:
|
|||
|
||||
$ docker -D info
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.9.0
|
||||
Storage Driver: aufs
|
||||
|
|
|
@ -192,6 +192,9 @@ These labels appear as part of the `docker info` output for the daemon:
|
|||
|
||||
$ docker -D info
|
||||
Containers: 12
|
||||
Running: 5
|
||||
Paused: 2
|
||||
Stopped: 5
|
||||
Images: 672
|
||||
Server Version: 1.9.0
|
||||
Storage Driver: aufs
|
||||
|
|
|
@ -28,6 +28,7 @@ type DockerSuite struct {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TearDownTest(c *check.C) {
|
||||
unpauseAllContainers()
|
||||
deleteAllContainers()
|
||||
deleteAllImages()
|
||||
deleteAllVolumes()
|
||||
|
|
|
@ -18,6 +18,9 @@ func (s *DockerSuite) TestInfoApi(c *check.C) {
|
|||
stringsToCheck := []string{
|
||||
"ID",
|
||||
"Containers",
|
||||
"ContainersRunning",
|
||||
"ContainersPaused",
|
||||
"ContainersStopped",
|
||||
"Images",
|
||||
"ExecutionDriver",
|
||||
"LoggingDriver",
|
||||
|
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/pkg/integration/checker"
|
||||
"github.com/docker/docker/utils"
|
||||
|
@ -17,6 +18,9 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
|
|||
stringsToCheck := []string{
|
||||
"ID:",
|
||||
"Containers:",
|
||||
" Running:",
|
||||
" Paused:",
|
||||
" Stopped:",
|
||||
"Images:",
|
||||
"Execution Driver:",
|
||||
"OSType:",
|
||||
|
@ -101,3 +105,44 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
|
|||
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster store: %s\n", discoveryBackend))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster advertise: %s:2375\n", ip.String()))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
dockerCmd(c, "run", "-d", "busybox", "top")
|
||||
out, _ := dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", 1))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", 1))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", 0))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 0))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "pause", cleanedContainerID)
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", 1))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", 0))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", 1))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 0))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "stop", cleanedContainerID)
|
||||
|
||||
out, _ = dockerCmd(c, "info")
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf("Containers: %d\n", 1))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Running: %d\n", 0))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Paused: %d\n", 0))
|
||||
c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 1))
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ Here is a sample output:
|
|||
|
||||
# docker info
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.9.0
|
||||
Storage Driver: aufs
|
||||
|
|
Загрузка…
Ссылка в новой задаче