Browse code

add links to inspect for 'linking' containers

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/06/26 07:24:14
Showing 1 changed files
... ...
@@ -2,6 +2,7 @@ package daemon
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
+	"fmt"
5 6
 
6 7
 	"github.com/dotcloud/docker/engine"
7 8
 	"github.com/dotcloud/docker/runconfig"
... ...
@@ -46,7 +47,16 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
46 46
 		out.Set("ProcessLabel", container.ProcessLabel)
47 47
 		out.SetJson("Volumes", container.Volumes)
48 48
 		out.SetJson("VolumesRW", container.VolumesRW)
49
+
50
+		if children, err := daemon.Children(container.Name); err == nil {
51
+			for linkAlias, child := range children {
52
+				container.hostConfig.Links = append(container.hostConfig.Links, fmt.Sprintf("%s:%s", child.Name, linkAlias))
53
+			}
54
+		}
55
+
49 56
 		out.SetJson("HostConfig", container.hostConfig)
57
+
58
+		container.hostConfig.Links = nil
50 59
 		if _, err := out.WriteTo(job.Stdout); err != nil {
51 60
 			return job.Error(err)
52 61
 		}