This preserves old behavior from sqlite links/names.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -601,6 +601,10 @@ func (daemon *Daemon) parents(c *container.Container) map[string]*container.Cont |
| 601 | 601 |
func (daemon *Daemon) registerLink(parent, child *container.Container, alias string) error {
|
| 602 | 602 |
fullName := path.Join(parent.Name, alias) |
| 603 | 603 |
if err := daemon.nameIndex.Reserve(fullName, child.ID); err != nil {
|
| 604 |
+ if err == registrar.ErrNameReserved {
|
|
| 605 |
+ logrus.Warnf("error registering link for %s, to %s, as alias %s, ignoring: %v", parent.ID, child.ID, alias, err)
|
|
| 606 |
+ return nil |
|
| 607 |
+ } |
|
| 604 | 608 |
return err |
| 605 | 609 |
} |
| 606 | 610 |
daemon.linkIndex.link(parent, child, fullName) |
| ... | ... |
@@ -212,3 +212,9 @@ func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *check.C) {
|
| 212 | 212 |
// /etc/hosts should be a regular file |
| 213 | 213 |
c.Assert(out, checker.Matches, "^-.+\n") |
| 214 | 214 |
} |
| 215 |
+ |
|
| 216 |
+func (s *DockerSuite) TestLinksMultipleWithSameName(c *check.C) {
|
|
| 217 |
+ dockerCmd(c, "run", "-d", "--name=upstream-a", "busybox", "top") |
|
| 218 |
+ dockerCmd(c, "run", "-d", "--name=upstream-b", "busybox", "top") |
|
| 219 |
+ dockerCmd(c, "run", "--link", "upstream-a:upstream", "--link", "upstream-b:upstream", "busybox", "sh", "-c", "ping -c 1 upstream") |
|
| 220 |
+} |