Remove network connection when link is removed

This commit is contained in:
Michael Crosby
2013-10-02 10:02:45 -07:00
parent 8c1fae65d3
commit 51db855bc3
3 changed files with 19 additions and 7 deletions
+2 -2
View File
@@ -762,8 +762,8 @@ func (cli *DockerCli) CmdRm(args ...string) error {
val.Set("link", "1")
}
for _, name := range cmd.Args() {
name = cleanName(name)
_, _, err := cli.call("DELETE", "/containers/"+name+"?"+val.Encode(), nil)
encName := cleanName(name)
_, _, err := cli.call("DELETE", "/containers/"+encName+"?"+val.Encode(), nil)
if err != nil {
fmt.Fprintf(cli.err, "%s\n", err)
} else {
+1 -1
View File
@@ -859,7 +859,7 @@ func (container *Container) Start(hostConfig *HostConfig) error {
return err
}
container.activeLinks[p] = link
container.activeLinks[link.Alias()] = link
if err := link.Enable(); err != nil {
rollback()
return err
+16 -4
View File
@@ -964,12 +964,24 @@ func (srv *Server) ContainerRestart(name string, t int) error {
func (srv *Server) ContainerDestroy(name string, removeVolume, removeLink bool) error {
if removeLink {
parent, _ := path.Split(name)
p := srv.runtime.containerGraph.Get(parent)
parentContainer := srv.runtime.Get(p.ID())
p := name
if p[0] != '/' {
p = "/" + p
}
parent, n := path.Split(p)
l := len(parent)
if parent[l-1] == '/' {
parent = parent[:l-1]
}
pe := srv.runtime.containerGraph.Get(parent)
parentContainer := srv.runtime.Get(pe.ID())
if parentContainer != nil && parentContainer.activeLinks != nil {
if link, exists := parentContainer.activeLinks[name]; exists {
if link, exists := parentContainer.activeLinks[n]; exists {
link.Disable()
} else {
utils.Debugf("Could not find active link for %s", name)
}
}