Add support for 'docker cp' to write to stdout
Closes #10805 Signed-off-by: Doug Davis <dug@us.ibm.com> Upstream-commit: f3d96e81e9c2a738ec577b814092f8953932de3a Component: engine
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -528,3 +529,30 @@ func TestCpToDot(t *testing.T) {
|
||||
}
|
||||
logDone("cp - to dot path")
|
||||
}
|
||||
|
||||
func TestCpToStdout(t *testing.T) {
|
||||
out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
|
||||
if err != nil || exitCode != 0 {
|
||||
t.Fatalf("failed to create a container:%s\n%s", out, err)
|
||||
}
|
||||
|
||||
cID := stripTrailingCharacters(out)
|
||||
defer deleteContainer(cID)
|
||||
|
||||
out, _, err = dockerCmd(t, "wait", cID)
|
||||
if err != nil || stripTrailingCharacters(out) != "0" {
|
||||
t.Fatalf("failed to set up container:%s\n%s", out, err)
|
||||
}
|
||||
|
||||
out, _, err = runCommandPipelineWithOutput(
|
||||
exec.Command(dockerBinary, "cp", cID+":/test", "-"),
|
||||
exec.Command("tar", "-vtf", "-"))
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to run commands: %s", err)
|
||||
}
|
||||
|
||||
if !strings.Contains(out, "test") || !strings.Contains(out, "-rw") {
|
||||
t.Fatalf("Missing file from tar TOC:\n%s", out)
|
||||
}
|
||||
logDone("cp - to stdout")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user