add daemon labels
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
998b591a71
commit
2fe36baa0a
|
|
@ -554,6 +554,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
if remoteInfo.Exists("IPv4Forwarding") && !remoteInfo.GetBool("IPv4Forwarding") {
|
if remoteInfo.Exists("IPv4Forwarding") && !remoteInfo.GetBool("IPv4Forwarding") {
|
||||||
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
|
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n")
|
||||||
}
|
}
|
||||||
|
if remoteInfo.Exists("Labels") {
|
||||||
|
fmt.Fprintln(cli.out, "Labels:")
|
||||||
|
for _, attribute := range remoteInfo.GetList("Labels") {
|
||||||
|
fmt.Fprintf(cli.out, " %s\n", attribute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ type Config struct {
|
||||||
EnableSelinuxSupport bool
|
EnableSelinuxSupport bool
|
||||||
Context map[string][]string
|
Context map[string][]string
|
||||||
TrustKeyPath string
|
TrustKeyPath string
|
||||||
|
Labels []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallFlags adds command-line options to the top-level flag parser for
|
// InstallFlags adds command-line options to the top-level flag parser for
|
||||||
|
|
@ -69,6 +70,7 @@ func (config *Config) InstallFlags() {
|
||||||
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
|
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
|
||||||
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
|
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
|
||||||
opts.MirrorListVar(&config.Mirrors, []string{"-registry-mirror"}, "Specify a preferred Docker registry mirror")
|
opts.MirrorListVar(&config.Mirrors, []string{"-registry-mirror"}, "Specify a preferred Docker registry mirror")
|
||||||
|
opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=values labels to the daemon (displayed in `docker info`)")
|
||||||
|
|
||||||
// Localhost is by default considered as an insecure registry
|
// Localhost is by default considered as an insecure registry
|
||||||
// This is a stop-gap for people who are running a private registry on localhost (especially on Boot2docker).
|
// This is a stop-gap for people who are running a private registry on localhost (especially on Boot2docker).
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
|
||||||
if hostname, err := os.Hostname(); err == nil {
|
if hostname, err := os.Hostname(); err == nil {
|
||||||
v.Set("Name", hostname)
|
v.Set("Name", hostname)
|
||||||
}
|
}
|
||||||
|
v.SetList("Labels", daemon.Config().Labels)
|
||||||
if _, err := v.WriteTo(job.Stdout); err != nil {
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
||||||
return job.Error(err)
|
return job.Error(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,9 @@ unix://[/path/to/socket] to use.
|
||||||
**-l**, **--log-level**="*debug*|*info*|*error*|*fatal*""
|
**-l**, **--log-level**="*debug*|*info*|*error*|*fatal*""
|
||||||
Set the logging level. Default is `info`.
|
Set the logging level. Default is `info`.
|
||||||
|
|
||||||
|
**--label**="[]"
|
||||||
|
Set key=values labels to the daemon (displayed in `docker info`)
|
||||||
|
|
||||||
**--mtu**=VALUE
|
**--mtu**=VALUE
|
||||||
Set the containers network mtu. Default is `1500`.
|
Set the containers network mtu. Default is `1500`.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,8 @@ You can still call an old version of the API using
|
||||||
|
|
||||||
**New!**
|
**New!**
|
||||||
`info` now returns the number of CPUs available on the machine (`NCPU`),
|
`info` now returns the number of CPUs available on the machine (`NCPU`),
|
||||||
total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), and a unique ID identifying the daemon (`ID`).
|
total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), a unique ID identifying the daemon (`ID`), and
|
||||||
|
a list of daemon labels (`Labels`).
|
||||||
|
|
||||||
`POST /containers/create`
|
`POST /containers/create`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1230,7 +1230,8 @@ Display system-wide information
|
||||||
"IndexServerAddress":["https://index.docker.io/v1/"],
|
"IndexServerAddress":["https://index.docker.io/v1/"],
|
||||||
"MemoryLimit":true,
|
"MemoryLimit":true,
|
||||||
"SwapLimit":false,
|
"SwapLimit":false,
|
||||||
"IPv4Forwarding":true
|
"IPv4Forwarding":true,
|
||||||
|
"Labels":["storage=ssd"]
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ expect an integer, and they can only be specified once.
|
||||||
--ip-masq=true Enable IP masquerading for bridge's IP range
|
--ip-masq=true Enable IP masquerading for bridge's IP range
|
||||||
--iptables=true Enable Docker's addition of iptables rules
|
--iptables=true Enable Docker's addition of iptables rules
|
||||||
-l, --log-level="info" Set the logging level
|
-l, --log-level="info" Set the logging level
|
||||||
|
--label=[] Set key=values labels to the daemon (displayed in `docker info`)
|
||||||
--mtu=0 Set the containers network MTU
|
--mtu=0 Set the containers network MTU
|
||||||
if no value is provided: default to the default route MTU or 1500 if no default route is available
|
if no value is provided: default to the default route MTU or 1500 if no default route is available
|
||||||
-p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file
|
-p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file
|
||||||
|
|
@ -851,7 +851,9 @@ For example:
|
||||||
$ sudo docker -D info
|
$ sudo docker -D info
|
||||||
Containers: 14
|
Containers: 14
|
||||||
Images: 52
|
Images: 52
|
||||||
Storage Driver: btrfs
|
Storage Driver: aufs
|
||||||
|
Root Dir: /var/lib/docker/aufs
|
||||||
|
Dirs: 545
|
||||||
Execution Driver: native-0.2
|
Execution Driver: native-0.2
|
||||||
Kernel Version: 3.13.0-24-generic
|
Kernel Version: 3.13.0-24-generic
|
||||||
Operating System: Ubuntu 14.04 LTS
|
Operating System: Ubuntu 14.04 LTS
|
||||||
|
|
@ -867,6 +869,8 @@ For example:
|
||||||
Init Path: /usr/bin/docker
|
Init Path: /usr/bin/docker
|
||||||
Username: svendowideit
|
Username: svendowideit
|
||||||
Registry: [https://index.docker.io/v1/]
|
Registry: [https://index.docker.io/v1/]
|
||||||
|
Labels:
|
||||||
|
storage=ssd
|
||||||
|
|
||||||
The global `-D` option tells all `docker` commands to output debug information.
|
The global `-D` option tells all `docker` commands to output debug information.
|
||||||
|
|
||||||
|
|
|
||||||
11
opts/opts.go
11
opts/opts.go
|
|
@ -43,6 +43,10 @@ func MirrorListVar(values *[]string, names []string, usage string) {
|
||||||
flag.Var(newListOptsRef(values, ValidateMirror), names, usage)
|
flag.Var(newListOptsRef(values, ValidateMirror), names, usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LabelListVar(values *[]string, names []string, usage string) {
|
||||||
|
flag.Var(newListOptsRef(values, ValidateLabel), names, usage)
|
||||||
|
}
|
||||||
|
|
||||||
// ListOpts type
|
// ListOpts type
|
||||||
type ListOpts struct {
|
type ListOpts struct {
|
||||||
values *[]string
|
values *[]string
|
||||||
|
|
@ -227,3 +231,10 @@ func ValidateMirror(val string) (string, error) {
|
||||||
|
|
||||||
return fmt.Sprintf("%s://%s/v1/", uri.Scheme, uri.Host), nil
|
return fmt.Sprintf("%s://%s/v1/", uri.Scheme, uri.Host), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ValidateLabel(val string) (string, error) {
|
||||||
|
if strings.Count(val, "=") != 1 {
|
||||||
|
return "", fmt.Errorf("bad attribute format: %s", val)
|
||||||
|
}
|
||||||
|
return val, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue