mirror of
https://github.com/clearlinux/docker.git
synced 2026-08-21 05:07:22 +00:00
Remove network connection when link is removed
This commit is contained in:
+2
-2
@@ -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
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user