mirror of
https://github.com/docker/docs.git
synced 2026-10-31 10:34:26 +03:00
replace 0.0.0.0 by node IP
This commit is contained in:
20
api/api.go
20
api/api.go
@@ -38,7 +38,7 @@ func getInfo(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
|
||||
MemoryLimit, SwapLimit, IPv4Forwarding bool
|
||||
}{
|
||||
len(c.cluster.Containers()),
|
||||
"libcluster", "libcluster",
|
||||
"libcluster", "libcluster", //TODO: remove this crap once https://github.com/docker/docker/pull/9131 is merged
|
||||
driverStatus,
|
||||
"N/A", "N/A",
|
||||
true, true, true,
|
||||
@@ -57,13 +57,21 @@ func getContainersJSON(c *HttpApiContext, w http.ResponseWriter, r *http.Request
|
||||
|
||||
all := r.Form.Get("all") == "1"
|
||||
|
||||
out := []dockerclient.Container{}
|
||||
out := []*dockerclient.Container{}
|
||||
for _, container := range c.cluster.Containers() {
|
||||
tmp := (*container).Container
|
||||
// Skip stopped containers unless -a was specified.
|
||||
if !strings.Contains(container.Status, "Up") && !all {
|
||||
if !strings.Contains(tmp.Status, "Up") && !all {
|
||||
continue
|
||||
}
|
||||
out = append(out, container.Container)
|
||||
tmp.Ports = make([]dockerclient.Port, len(container.Ports))
|
||||
for i, port := range container.Ports {
|
||||
tmp.Ports[i] = port
|
||||
if port.IP == "0.0.0.0" {
|
||||
tmp.Ports[i].IP = container.Node().IP
|
||||
}
|
||||
}
|
||||
out = append(out, &tmp)
|
||||
}
|
||||
|
||||
sort.Sort(sort.Reverse(ContainerSorter(out)))
|
||||
@@ -103,7 +111,7 @@ func postContainersStart(c *HttpApiContext, w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
// POST /containers/{name:.*}/pause
|
||||
func postContainersPause(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
|
||||
func postContainerPause(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
|
||||
name := mux.Vars(r)["name"]
|
||||
container := c.cluster.Container(name)
|
||||
if container == nil {
|
||||
@@ -117,7 +125,7 @@ func postContainersPause(c *HttpApiContext, w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
|
||||
// POST /containers/{name:.*}/unpause
|
||||
func postContainersUnpause(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
|
||||
func postContainerUnpause(c *HttpApiContext, w http.ResponseWriter, r *http.Request) {
|
||||
name := mux.Vars(r)["name"]
|
||||
container := c.cluster.Container(name)
|
||||
if container == nil {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/samalba/dockerclient"
|
||||
)
|
||||
|
||||
type ContainerSorter []dockerclient.Container
|
||||
type ContainerSorter []*dockerclient.Container
|
||||
|
||||
func (s ContainerSorter) Len() int {
|
||||
return len(s)
|
||||
|
||||
@@ -32,6 +32,6 @@ func (c *Container) Pause() error {
|
||||
return c.node.client.PauseContainer(c.Id)
|
||||
}
|
||||
|
||||
func (c *Container) Unpause(timeout int) error {
|
||||
func (c *Container) Unpause() error {
|
||||
return c.node.client.UnpauseContainer(c.Id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user