mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
Fix --link to a container which net mode is container mode
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
@@ -379,6 +379,39 @@ func TestRunLinksContainerWithContainerId(t *testing.T) {
|
||||
logDone("run - use a container id to link target work")
|
||||
}
|
||||
|
||||
func TestRunLinkToContainerNetMode(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
|
||||
cmd := exec.Command(dockerBinary, "run", "--name", "test", "-d", "busybox", "top")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||
}
|
||||
cmd = exec.Command(dockerBinary, "run", "--name", "parent", "-d", "--net=container:test", "busybox", "top")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||
}
|
||||
cmd = exec.Command(dockerBinary, "run", "-d", "--link=parent:parent", "busybox", "top")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||
}
|
||||
|
||||
cmd = exec.Command(dockerBinary, "run", "--name", "child", "-d", "--net=container:parent", "busybox", "top")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||
}
|
||||
cmd = exec.Command(dockerBinary, "run", "-d", "--link=child:child", "busybox", "top")
|
||||
out, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to run container: %v, output: %q", err, out)
|
||||
}
|
||||
|
||||
logDone("run - link to a container which net mode is container success")
|
||||
}
|
||||
|
||||
// Regression test for #4741
|
||||
func TestRunWithVolumesAsFiles(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
|
||||
Reference in New Issue
Block a user