|
@@ -8,6 +8,7 @@ import (
|
|
"github.com/dotcloud/docker/engine"
|
|
"github.com/dotcloud/docker/engine"
|
|
"github.com/dotcloud/docker/execdriver"
|
|
"github.com/dotcloud/docker/execdriver"
|
|
"github.com/dotcloud/docker/graphdriver"
|
|
"github.com/dotcloud/docker/graphdriver"
|
|
|
|
+ "github.com/dotcloud/docker/links"
|
|
"github.com/dotcloud/docker/nat"
|
|
"github.com/dotcloud/docker/nat"
|
|
"github.com/dotcloud/docker/pkg/mount"
|
|
"github.com/dotcloud/docker/pkg/mount"
|
|
"github.com/dotcloud/docker/pkg/term"
|
|
"github.com/dotcloud/docker/pkg/term"
|
|
@@ -71,7 +72,7 @@ type Container struct {
|
|
VolumesRW map[string]bool
|
|
VolumesRW map[string]bool
|
|
hostConfig *runconfig.HostConfig
|
|
hostConfig *runconfig.HostConfig
|
|
|
|
|
|
- activeLinks map[string]*Link
|
|
|
|
|
|
+ activeLinks map[string]*links.Link
|
|
}
|
|
}
|
|
|
|
|
|
type BindMap struct {
|
|
type BindMap struct {
|
|
@@ -537,7 +538,7 @@ func (container *Container) Start() (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
if len(children) > 0 {
|
|
if len(children) > 0 {
|
|
- container.activeLinks = make(map[string]*Link, len(children))
|
|
|
|
|
|
+ container.activeLinks = make(map[string]*links.Link, len(children))
|
|
|
|
|
|
// If we encounter an error make sure that we rollback any network
|
|
// If we encounter an error make sure that we rollback any network
|
|
// config and ip table changes
|
|
// config and ip table changes
|
|
@@ -548,8 +549,19 @@ func (container *Container) Start() (err error) {
|
|
container.activeLinks = nil
|
|
container.activeLinks = nil
|
|
}
|
|
}
|
|
|
|
|
|
- for p, child := range children {
|
|
|
|
- link, err := NewLink(container, child, p, runtime.eng)
|
|
|
|
|
|
+ for linkAlias, child := range children {
|
|
|
|
+ if !child.State.IsRunning() {
|
|
|
|
+ return fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, linkAlias)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ link, err := links.NewLink(
|
|
|
|
+ container.NetworkSettings.IPAddress,
|
|
|
|
+ child.NetworkSettings.IPAddress,
|
|
|
|
+ linkAlias,
|
|
|
|
+ child.Config.Env,
|
|
|
|
+ child.Config.ExposedPorts,
|
|
|
|
+ runtime.eng)
|
|
|
|
+
|
|
if err != nil {
|
|
if err != nil {
|
|
rollback()
|
|
rollback()
|
|
return err
|
|
return err
|