Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
moby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
emulab
moby
Commits
1dae7a25
Commit
1dae7a25
authored
11 years ago
by
Guillaume J. Charmes
Browse files
Options
Downloads
Patches
Plain Diff
Improve the docker version and docker info commands
parent
926c1d45
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api_params.go
+10
-11
10 additions, 11 deletions
api_params.go
commands.go
+21
-13
21 additions, 13 deletions
commands.go
server.go
+15
-13
15 additions, 13 deletions
server.go
with
46 additions
and
37 deletions
api_params.go
+
10
−
11
View file @
1dae7a25
...
...
@@ -3,7 +3,7 @@ package docker
type
ApiHistory
struct
{
Id
string
Created
int64
CreatedBy
string
CreatedBy
string
`json:",omitempty"`
}
type
ApiImages
struct
{
...
...
@@ -14,13 +14,13 @@ type ApiImages struct {
}
type
ApiInfo
struct
{
Debug
bool
Containers
int
Version
string
Images
int
Debug
bool
Go
Version
string
NFd
int
`json:",omitempty"`
NGoroutines
int
`json:",omitempty"`
NFd
int
`json:",omitempty"`
N
Go
routines
int
`json:",omitempty"`
MemoryLimit
bool
`json:",omitempty"`
SwapLimit
bool
`json:",omitempty"`
}
type
ApiContainers
struct
{
...
...
@@ -43,7 +43,7 @@ type ApiId struct {
type
ApiRun
struct
{
Id
string
Warnings
[]
string
Warnings
[]
string
`json:",omitempty"`
}
type
ApiPort
struct
{
...
...
@@ -51,10 +51,9 @@ type ApiPort struct {
}
type
ApiVersion
struct
{
Version
string
GitCommit
string
MemoryLimit
bool
SwapLimit
bool
Version
string
GitCommit
string
`json:",omitempty"`
GoVersion
string
`json:",omitempty"`
}
type
ApiWait
struct
{
...
...
This diff is collapsed.
Click to expand it.
commands.go
+
21
−
13
View file @
1dae7a25
...
...
@@ -391,15 +391,14 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
utils
.
Debugf
(
"Error unmarshal: body: %s, err: %s
\n
"
,
body
,
err
)
return
err
}
fmt
.
Println
(
"
V
ersion:"
,
out
.
Version
)
fmt
.
Println
(
"
Git Commit:"
,
out
.
GitCommit
)
if
!
out
.
MemoryLimit
{
fmt
.
Println
(
"
WARNING: No memory limit support"
)
fmt
.
Println
(
"
Client v
ersion:"
,
VERSION
)
fmt
.
Println
(
"
Server version:"
,
out
.
Version
)
if
out
.
GitCommit
!=
""
{
fmt
.
Println
(
"
Git commit:"
,
out
.
GitCommit
)
}
if
!
out
.
SwapLimit
{
fmt
.
Println
(
"
WARNING: No swap limit support"
)
if
out
.
GoVersion
!=
""
{
fmt
.
Println
(
"
Go version:"
,
out
.
GoVersion
)
}
return
nil
}
...
...
@@ -420,14 +419,23 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
}
var
out
ApiInfo
err
=
json
.
Unmarshal
(
body
,
&
out
)
if
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
body
,
&
out
);
err
!=
nil
{
return
err
}
fmt
.
Printf
(
"containers: %d
\n
version: %s
\n
images: %d
\n
Go version: %s
\n
"
,
out
.
Containers
,
out
.
Version
,
out
.
Images
,
out
.
GoVersion
)
if
out
.
Debug
{
fmt
.
Println
(
"debug mode enabled"
)
fmt
.
Printf
(
"fds: %d
\n
goroutines: %d
\n
"
,
out
.
NFd
,
out
.
NGoroutines
)
fmt
.
Printf
(
"Containers: %d
\n
"
,
out
.
Containers
)
fmt
.
Printf
(
"Images: %d
\n
"
,
out
.
Images
)
if
out
.
Debug
||
os
.
Getenv
(
"DEBUG"
)
!=
""
{
fmt
.
Printf
(
"Debug mode (server): %v
\n
"
,
out
.
Debug
)
fmt
.
Printf
(
"Debug mode (client): %v
\n
"
,
os
.
Getenv
(
"DEBUG"
)
!=
""
)
fmt
.
Printf
(
"Fds: %d
\n
"
,
out
.
NFd
)
fmt
.
Printf
(
"Goroutines: %d
\n
"
,
out
.
NGoroutines
)
}
if
!
out
.
MemoryLimit
{
fmt
.
Println
(
"WARNING: No memory limit support"
)
}
if
!
out
.
SwapLimit
{
fmt
.
Println
(
"WARNING: No swap limit support"
)
}
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
server.go
+
15
−
13
View file @
1dae7a25
...
...
@@ -17,7 +17,11 @@ import (
)
func
(
srv
*
Server
)
DockerVersion
()
ApiVersion
{
return
ApiVersion
{
VERSION
,
GIT_COMMIT
,
srv
.
runtime
.
capabilities
.
MemoryLimit
,
srv
.
runtime
.
capabilities
.
SwapLimit
}
return
ApiVersion
{
Version
:
VERSION
,
GitCommit
:
GIT_COMMIT
,
GoVersion
:
runtime
.
Version
(),
}
}
func
(
srv
*
Server
)
ContainerKill
(
name
string
)
error
{
...
...
@@ -187,7 +191,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) {
return
outs
,
nil
}
func
(
srv
*
Server
)
DockerInfo
()
ApiInfo
{
func
(
srv
*
Server
)
DockerInfo
()
*
ApiInfo
{
images
,
_
:=
srv
.
runtime
.
graph
.
All
()
var
imgcount
int
if
images
==
nil
{
...
...
@@ -195,17 +199,15 @@ func (srv *Server) DockerInfo() ApiInfo {
}
else
{
imgcount
=
len
(
images
)
}
var
out
ApiInfo
out
.
Containers
=
len
(
srv
.
runtime
.
List
())
out
.
Version
=
VERSION
out
.
Images
=
imgcount
out
.
GoVersion
=
runtime
.
Version
()
if
os
.
Getenv
(
"DEBUG"
)
!=
""
{
out
.
Debug
=
true
out
.
NFd
=
utils
.
GetTotalUsedFds
()
out
.
NGoroutines
=
runtime
.
NumGoroutine
()
}
return
out
return
&
ApiInfo
{
Containers
:
len
(
srv
.
runtime
.
List
()),
Images
:
imgcount
,
MemoryLimit
:
srv
.
runtime
.
capabilities
.
MemoryLimit
,
SwapLimit
:
srv
.
runtime
.
capabilities
.
SwapLimit
,
Debug
:
os
.
Getenv
(
"DEBUG"
)
!=
""
,
NFd
:
utils
.
GetTotalUsedFds
(),
NGoroutines
:
runtime
.
NumGoroutine
(),
}
}
func
(
srv
*
Server
)
ImageHistory
(
name
string
)
([]
ApiHistory
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment