diff --git a/api/types/swarm/node.go b/api/types/swarm/node.go index 028b67d6f8..379e17a779 100644 --- a/api/types/swarm/node.go +++ b/api/types/swarm/node.go @@ -77,6 +77,7 @@ type PluginDescription struct { type NodeStatus struct { State NodeState `json:",omitempty"` Message string `json:",omitempty"` + Addr string `json:",omitempty"` } // Reachability represents the reachability of a node. diff --git a/cli/command/node/inspect.go b/cli/command/node/inspect.go index 0812ec5eab..fde70185f8 100644 --- a/cli/command/node/inspect.go +++ b/cli/command/node/inspect.go @@ -95,6 +95,7 @@ func printNode(out io.Writer, node swarm.Node) { fmt.Fprintf(out, " State:\t\t\t%s\n", command.PrettyPrint(node.Status.State)) ioutils.FprintfIfNotEmpty(out, " Message:\t\t%s\n", command.PrettyPrint(node.Status.Message)) fmt.Fprintf(out, " Availability:\t\t%s\n", command.PrettyPrint(node.Spec.Availability)) + ioutils.FprintfIfNotEmpty(out, " Address:\t\t%s\n", command.PrettyPrint(node.Status.Addr)) if node.ManagerStatus != nil { fmt.Fprintln(out, "Manager Status:") diff --git a/daemon/cluster/convert/node.go b/daemon/cluster/convert/node.go index 8422b7a36c..306f34e0b2 100644 --- a/daemon/cluster/convert/node.go +++ b/daemon/cluster/convert/node.go @@ -20,6 +20,7 @@ func NodeFromGRPC(n swarmapi.Node) types.Node { Status: types.NodeStatus{ State: types.NodeState(strings.ToLower(n.Status.State.String())), Message: n.Status.Message, + Addr: n.Status.Addr, }, } diff --git a/docs/reference/api/docker_remote_api.md b/docs/reference/api/docker_remote_api.md index ec1b7cff7e..79a45469b8 100644 --- a/docs/reference/api/docker_remote_api.md +++ b/docs/reference/api/docker_remote_api.md @@ -163,6 +163,7 @@ This section lists each version from latest to oldest. Each listing includes a * Every API response now includes a `Docker-Experimental` header specifying if experimental features are enabled (value can be `true` or `false`). * The `hostConfig` option now accepts the fields `CpuRealtimePeriod` and `CpuRtRuntime` to allocate cpu runtime to rt tasks when `CONFIG_RT_GROUP_SCHED` is enabled in the kernel. * The `SecurityOptions` field within the `GET /info` response now includes `userns` if user namespaces are enabled in the daemon. +* `GET /nodes` and `GET /node/(id or name)` now return `Addr` as part of a node's `Status`, which is the address that that node connects to the manager from. ### v1.24 API changes diff --git a/docs/reference/api/docker_remote_api_v1.25.md b/docs/reference/api/docker_remote_api_v1.25.md index 0b58cb023d..5c495f029a 100644 --- a/docs/reference/api/docker_remote_api_v1.25.md +++ b/docs/reference/api/docker_remote_api_v1.25.md @@ -4464,7 +4464,8 @@ List nodes } }, "Status": { - "State": "ready" + "State": "ready", + "Addr": "172.17.0.2" }, "ManagerStatus": { "Leader": true, @@ -4555,7 +4556,8 @@ Return low-level information on the node `id` } }, "Status": { - "State": "ready" + "State": "ready", + "Addr": "172.17.0.2" }, "ManagerStatus": { "Leader": true, diff --git a/docs/reference/commandline/node_inspect.md b/docs/reference/commandline/node_inspect.md index f5e644073a..752951c6f5 100644 --- a/docs/reference/commandline/node_inspect.md +++ b/docs/reference/commandline/node_inspect.md @@ -88,7 +88,8 @@ Example output: } }, "Status": { - "State": "ready" + "State": "ready", + "Addr": "168.0.32.137" }, "ManagerStatus": { "Leader": true, @@ -110,6 +111,7 @@ Example output: Status: State: Ready Availability: Active + Address: 172.17.0.2 Manager Status: Address: 172.17.0.2:2377 Raft Status: Reachable