Signed-off-by: Victor Vieux <vieux@docker.com>
| ... | ... |
@@ -554,6 +554,13 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
| 554 | 554 |
if remoteInfo.Exists("IPv4Forwarding") && !remoteInfo.GetBool("IPv4Forwarding") {
|
| 555 | 555 |
fmt.Fprintf(cli.err, "WARNING: IPv4 forwarding is disabled.\n") |
| 556 | 556 |
} |
| 557 |
+ if remoteInfo.Exists("Labels") {
|
|
| 558 |
+ fmt.Fprintln(cli.out, "Labels:") |
|
| 559 |
+ for _, attribute := range remoteInfo.GetList("Labels") {
|
|
| 560 |
+ fmt.Fprintf(cli.out, " %s\n", attribute) |
|
| 561 |
+ } |
|
| 562 |
+ } |
|
| 563 |
+ |
|
| 557 | 564 |
return nil |
| 558 | 565 |
} |
| 559 | 566 |
|
| ... | ... |
@@ -41,6 +41,7 @@ type Config struct {
|
| 41 | 41 |
EnableSelinuxSupport bool |
| 42 | 42 |
Context map[string][]string |
| 43 | 43 |
TrustKeyPath string |
| 44 |
+ Labels []string |
|
| 44 | 45 |
} |
| 45 | 46 |
|
| 46 | 47 |
// InstallFlags adds command-line options to the top-level flag parser for |
| ... | ... |
@@ -69,6 +70,7 @@ func (config *Config) InstallFlags() {
|
| 69 | 69 |
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers")
|
| 70 | 70 |
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
|
| 71 | 71 |
opts.MirrorListVar(&config.Mirrors, []string{"-registry-mirror"}, "Specify a preferred Docker registry mirror")
|
| 72 |
+ opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=values labels to the daemon (displayed in `docker info`)")
|
|
| 72 | 73 |
|
| 73 | 74 |
// Localhost is by default considered as an insecure registry |
| 74 | 75 |
// 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 {
|
| 79 | 79 |
if hostname, err := os.Hostname(); err == nil {
|
| 80 | 80 |
v.Set("Name", hostname)
|
| 81 | 81 |
} |
| 82 |
+ v.SetList("Labels", daemon.Config().Labels)
|
|
| 82 | 83 |
if _, err := v.WriteTo(job.Stdout); err != nil {
|
| 83 | 84 |
return job.Error(err) |
| 84 | 85 |
} |
| ... | ... |
@@ -68,6 +68,9 @@ unix://[/path/to/socket] to use. |
| 68 | 68 |
**-l**, **--log-level**="*debug*|*info*|*error*|*fatal*"" |
| 69 | 69 |
Set the logging level. Default is `info`. |
| 70 | 70 |
|
| 71 |
+**--label**="[]" |
|
| 72 |
+ Set key=values labels to the daemon (displayed in `docker info`) |
|
| 73 |
+ |
|
| 71 | 74 |
**--mtu**=VALUE |
| 72 | 75 |
Set the containers network mtu. Default is `1500`. |
| 73 | 76 |
|
| ... | ... |
@@ -50,7 +50,8 @@ You can still call an old version of the API using |
| 50 | 50 |
|
| 51 | 51 |
**New!** |
| 52 | 52 |
`info` now returns the number of CPUs available on the machine (`NCPU`), |
| 53 |
-total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), and a unique ID identifying the daemon (`ID`). |
|
| 53 |
+total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), a unique ID identifying the daemon (`ID`), and |
|
| 54 |
+a list of daemon labels (`Labels`). |
|
| 54 | 55 |
|
| 55 | 56 |
`POST /containers/create` |
| 56 | 57 |
|
| ... | ... |
@@ -1230,7 +1230,8 @@ Display system-wide information |
| 1230 | 1230 |
"IndexServerAddress":["https://index.docker.io/v1/"], |
| 1231 | 1231 |
"MemoryLimit":true, |
| 1232 | 1232 |
"SwapLimit":false, |
| 1233 |
- "IPv4Forwarding":true |
|
| 1233 |
+ "IPv4Forwarding":true, |
|
| 1234 |
+ "Labels":["storage=ssd"] |
|
| 1234 | 1235 |
} |
| 1235 | 1236 |
|
| 1236 | 1237 |
Status Codes: |
| ... | ... |
@@ -76,7 +76,7 @@ expect an integer, and they can only be specified once. |
| 76 | 76 |
--ip-masq=true Enable IP masquerading for bridge's IP range |
| 77 | 77 |
--iptables=true Enable Docker's addition of iptables rules |
| 78 | 78 |
-l, --log-level="info" Set the logging level |
| 79 |
- |
|
| 79 |
+ --label=[] Set key=values labels to the daemon (displayed in `docker info`) |
|
| 80 | 80 |
--mtu=0 Set the containers network MTU |
| 81 | 81 |
if no value is provided: default to the default route MTU or 1500 if no default route is available |
| 82 | 82 |
-p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file |
| ... | ... |
@@ -851,7 +851,9 @@ For example: |
| 851 | 851 |
$ sudo docker -D info |
| 852 | 852 |
Containers: 14 |
| 853 | 853 |
Images: 52 |
| 854 |
- Storage Driver: btrfs |
|
| 854 |
+ Storage Driver: aufs |
|
| 855 |
+ Root Dir: /var/lib/docker/aufs |
|
| 856 |
+ Dirs: 545 |
|
| 855 | 857 |
Execution Driver: native-0.2 |
| 856 | 858 |
Kernel Version: 3.13.0-24-generic |
| 857 | 859 |
Operating System: Ubuntu 14.04 LTS |
| ... | ... |
@@ -867,6 +869,8 @@ For example: |
| 867 | 867 |
Init Path: /usr/bin/docker |
| 868 | 868 |
Username: svendowideit |
| 869 | 869 |
Registry: [https://index.docker.io/v1/] |
| 870 |
+ Labels: |
|
| 871 |
+ storage=ssd |
|
| 870 | 872 |
|
| 871 | 873 |
The global `-D` option tells all `docker` commands to output debug information. |
| 872 | 874 |
|
| ... | ... |
@@ -43,6 +43,10 @@ func MirrorListVar(values *[]string, names []string, usage string) {
|
| 43 | 43 |
flag.Var(newListOptsRef(values, ValidateMirror), names, usage) |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
+func LabelListVar(values *[]string, names []string, usage string) {
|
|
| 47 |
+ flag.Var(newListOptsRef(values, ValidateLabel), names, usage) |
|
| 48 |
+} |
|
| 49 |
+ |
|
| 46 | 50 |
// ListOpts type |
| 47 | 51 |
type ListOpts struct {
|
| 48 | 52 |
values *[]string |
| ... | ... |
@@ -227,3 +231,10 @@ func ValidateMirror(val string) (string, error) {
|
| 227 | 227 |
|
| 228 | 228 |
return fmt.Sprintf("%s://%s/v1/", uri.Scheme, uri.Host), nil
|
| 229 | 229 |
} |
| 230 |
+ |
|
| 231 |
+func ValidateLabel(val string) (string, error) {
|
|
| 232 |
+ if strings.Count(val, "=") != 1 {
|
|
| 233 |
+ return "", fmt.Errorf("bad attribute format: %s", val)
|
|
| 234 |
+ } |
|
| 235 |
+ return val, nil |
|
| 236 |
+} |