Browse Source

Merge pull request #9014 from LK4D4/fix_parent_failing

Not fail on updating parent links
Michael Crosby 10 years ago
parent
commit
84f25414c1
2 changed files with 21 additions and 1 deletions
  1. 1 1
      daemon/container.go
  2. 20 0
      integration-cli/docker_cli_links_test.go

+ 1 - 1
daemon/container.go

@@ -987,7 +987,7 @@ func (container *Container) updateParentsHosts() error {
 		c := container.daemon.Get(cid)
 		if c != nil && !container.daemon.config.DisableNetwork && container.hostConfig.NetworkMode.IsPrivate() {
 			if err := etchosts.Update(c.HostsPath, container.NetworkSettings.IPAddress, container.Name[1:]); err != nil {
-				return fmt.Errorf("Failed to update /etc/hosts in parent container: %v", err)
+				log.Errorf("Failed to update /etc/hosts in parent container: %v", err)
 			}
 		}
 	}

+ 20 - 0
integration-cli/docker_cli_links_test.go

@@ -157,3 +157,23 @@ func TestLinksInspectLinksStopped(t *testing.T) {
 
 	logDone("link - links in stopped container inspect")
 }
+
+func TestLinksNotStartedParentNotFail(t *testing.T) {
+	defer deleteAllContainers()
+	runCmd := exec.Command(dockerBinary, "create", "--name=first", "busybox", "top")
+	out, _, _, err := runCommandWithStdoutStderr(runCmd)
+	if err != nil {
+		t.Fatal(out, err)
+	}
+	runCmd = exec.Command(dockerBinary, "create", "--name=second", "--link=first:first", "busybox", "top")
+	out, _, _, err = runCommandWithStdoutStderr(runCmd)
+	if err != nil {
+		t.Fatal(out, err)
+	}
+	runCmd = exec.Command(dockerBinary, "start", "first")
+	out, _, _, err = runCommandWithStdoutStderr(runCmd)
+	if err != nil {
+		t.Fatal(out, err)
+	}
+	logDone("link - container start not failing on updating stopped parent links")
+}