docker_cli_cp_test.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. package main
  2. import (
  3. "bytes"
  4. "fmt"
  5. "io/ioutil"
  6. "os"
  7. "os/exec"
  8. "path"
  9. "path/filepath"
  10. "strings"
  11. "github.com/go-check/check"
  12. )
  13. const (
  14. cpTestPathParent = "/some"
  15. cpTestPath = "/some/path"
  16. cpTestName = "test"
  17. cpFullPath = "/some/path/test"
  18. cpContainerContents = "holla, i am the container"
  19. cpHostContents = "hello, i am the host"
  20. )
  21. // Ensure that an all-local path case returns an error.
  22. func (s *DockerSuite) TestCpLocalOnly(c *check.C) {
  23. err := runDockerCp(c, "foo", "bar")
  24. if err == nil {
  25. c.Fatal("expected failure, got success")
  26. }
  27. if !strings.Contains(err.Error(), "must specify at least one container source") {
  28. c.Fatalf("unexpected output: %s", err.Error())
  29. }
  30. }
  31. // Test for #5656
  32. // Check that garbage paths don't escape the container's rootfs
  33. func (s *DockerSuite) TestCpGarbagePath(c *check.C) {
  34. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
  35. if exitCode != 0 {
  36. c.Fatal("failed to create a container", out)
  37. }
  38. cleanedContainerID := strings.TrimSpace(out)
  39. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  40. if strings.TrimSpace(out) != "0" {
  41. c.Fatal("failed to set up container", out)
  42. }
  43. if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
  44. c.Fatal(err)
  45. }
  46. hostFile, err := os.Create(cpFullPath)
  47. if err != nil {
  48. c.Fatal(err)
  49. }
  50. defer hostFile.Close()
  51. defer os.RemoveAll(cpTestPathParent)
  52. fmt.Fprintf(hostFile, "%s", cpHostContents)
  53. tmpdir, err := ioutil.TempDir("", "docker-integration")
  54. if err != nil {
  55. c.Fatal(err)
  56. }
  57. tmpname := filepath.Join(tmpdir, cpTestName)
  58. defer os.RemoveAll(tmpdir)
  59. path := path.Join("../../../../../../../../../../../../", cpFullPath)
  60. dockerCmd(c, "cp", cleanedContainerID+":"+path, tmpdir)
  61. file, _ := os.Open(tmpname)
  62. defer file.Close()
  63. test, err := ioutil.ReadAll(file)
  64. if err != nil {
  65. c.Fatal(err)
  66. }
  67. if string(test) == cpHostContents {
  68. c.Errorf("output matched host file -- garbage path can escape container rootfs")
  69. }
  70. if string(test) != cpContainerContents {
  71. c.Errorf("output doesn't match the input for garbage path")
  72. }
  73. }
  74. // Check that relative paths are relative to the container's rootfs
  75. func (s *DockerSuite) TestCpRelativePath(c *check.C) {
  76. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
  77. if exitCode != 0 {
  78. c.Fatal("failed to create a container", out)
  79. }
  80. cleanedContainerID := strings.TrimSpace(out)
  81. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  82. if strings.TrimSpace(out) != "0" {
  83. c.Fatal("failed to set up container", out)
  84. }
  85. if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
  86. c.Fatal(err)
  87. }
  88. hostFile, err := os.Create(cpFullPath)
  89. if err != nil {
  90. c.Fatal(err)
  91. }
  92. defer hostFile.Close()
  93. defer os.RemoveAll(cpTestPathParent)
  94. fmt.Fprintf(hostFile, "%s", cpHostContents)
  95. tmpdir, err := ioutil.TempDir("", "docker-integration")
  96. if err != nil {
  97. c.Fatal(err)
  98. }
  99. tmpname := filepath.Join(tmpdir, cpTestName)
  100. defer os.RemoveAll(tmpdir)
  101. var relPath string
  102. if path.IsAbs(cpFullPath) {
  103. // normally this is `filepath.Rel("/", cpFullPath)` but we cannot
  104. // get this unix-path manipulation on windows with filepath.
  105. relPath = cpFullPath[1:]
  106. } else {
  107. c.Fatalf("path %s was assumed to be an absolute path", cpFullPath)
  108. }
  109. dockerCmd(c, "cp", cleanedContainerID+":"+relPath, tmpdir)
  110. file, _ := os.Open(tmpname)
  111. defer file.Close()
  112. test, err := ioutil.ReadAll(file)
  113. if err != nil {
  114. c.Fatal(err)
  115. }
  116. if string(test) == cpHostContents {
  117. c.Errorf("output matched host file -- relative path can escape container rootfs")
  118. }
  119. if string(test) != cpContainerContents {
  120. c.Errorf("output doesn't match the input for relative path")
  121. }
  122. }
  123. // Check that absolute paths are relative to the container's rootfs
  124. func (s *DockerSuite) TestCpAbsolutePath(c *check.C) {
  125. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath)
  126. if exitCode != 0 {
  127. c.Fatal("failed to create a container", out)
  128. }
  129. cleanedContainerID := strings.TrimSpace(out)
  130. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  131. if strings.TrimSpace(out) != "0" {
  132. c.Fatal("failed to set up container", out)
  133. }
  134. if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
  135. c.Fatal(err)
  136. }
  137. hostFile, err := os.Create(cpFullPath)
  138. if err != nil {
  139. c.Fatal(err)
  140. }
  141. defer hostFile.Close()
  142. defer os.RemoveAll(cpTestPathParent)
  143. fmt.Fprintf(hostFile, "%s", cpHostContents)
  144. tmpdir, err := ioutil.TempDir("", "docker-integration")
  145. if err != nil {
  146. c.Fatal(err)
  147. }
  148. tmpname := filepath.Join(tmpdir, cpTestName)
  149. defer os.RemoveAll(tmpdir)
  150. path := cpFullPath
  151. dockerCmd(c, "cp", cleanedContainerID+":"+path, tmpdir)
  152. file, _ := os.Open(tmpname)
  153. defer file.Close()
  154. test, err := ioutil.ReadAll(file)
  155. if err != nil {
  156. c.Fatal(err)
  157. }
  158. if string(test) == cpHostContents {
  159. c.Errorf("output matched host file -- absolute path can escape container rootfs")
  160. }
  161. if string(test) != cpContainerContents {
  162. c.Errorf("output doesn't match the input for absolute path")
  163. }
  164. }
  165. // Test for #5619
  166. // Check that absolute symlinks are still relative to the container's rootfs
  167. func (s *DockerSuite) TestCpAbsoluteSymlink(c *check.C) {
  168. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path")
  169. if exitCode != 0 {
  170. c.Fatal("failed to create a container", out)
  171. }
  172. cleanedContainerID := strings.TrimSpace(out)
  173. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  174. if strings.TrimSpace(out) != "0" {
  175. c.Fatal("failed to set up container", out)
  176. }
  177. if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
  178. c.Fatal(err)
  179. }
  180. hostFile, err := os.Create(cpFullPath)
  181. if err != nil {
  182. c.Fatal(err)
  183. }
  184. defer hostFile.Close()
  185. defer os.RemoveAll(cpTestPathParent)
  186. fmt.Fprintf(hostFile, "%s", cpHostContents)
  187. tmpdir, err := ioutil.TempDir("", "docker-integration")
  188. if err != nil {
  189. c.Fatal(err)
  190. }
  191. tmpname := filepath.Join(tmpdir, cpTestName)
  192. defer os.RemoveAll(tmpdir)
  193. path := path.Join("/", "container_path")
  194. dockerCmd(c, "cp", cleanedContainerID+":"+path, tmpdir)
  195. file, _ := os.Open(tmpname)
  196. defer file.Close()
  197. test, err := ioutil.ReadAll(file)
  198. if err != nil {
  199. c.Fatal(err)
  200. }
  201. if string(test) == cpHostContents {
  202. c.Errorf("output matched host file -- absolute symlink can escape container rootfs")
  203. }
  204. if string(test) != cpContainerContents {
  205. c.Errorf("output doesn't match the input for absolute symlink")
  206. }
  207. }
  208. // Test for #5619
  209. // Check that symlinks which are part of the resource path are still relative to the container's rootfs
  210. func (s *DockerSuite) TestCpSymlinkComponent(c *check.C) {
  211. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path")
  212. if exitCode != 0 {
  213. c.Fatal("failed to create a container", out)
  214. }
  215. cleanedContainerID := strings.TrimSpace(out)
  216. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  217. if strings.TrimSpace(out) != "0" {
  218. c.Fatal("failed to set up container", out)
  219. }
  220. if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil {
  221. c.Fatal(err)
  222. }
  223. hostFile, err := os.Create(cpFullPath)
  224. if err != nil {
  225. c.Fatal(err)
  226. }
  227. defer hostFile.Close()
  228. defer os.RemoveAll(cpTestPathParent)
  229. fmt.Fprintf(hostFile, "%s", cpHostContents)
  230. tmpdir, err := ioutil.TempDir("", "docker-integration")
  231. if err != nil {
  232. c.Fatal(err)
  233. }
  234. tmpname := filepath.Join(tmpdir, cpTestName)
  235. defer os.RemoveAll(tmpdir)
  236. path := path.Join("/", "container_path", cpTestName)
  237. dockerCmd(c, "cp", cleanedContainerID+":"+path, tmpdir)
  238. file, _ := os.Open(tmpname)
  239. defer file.Close()
  240. test, err := ioutil.ReadAll(file)
  241. if err != nil {
  242. c.Fatal(err)
  243. }
  244. if string(test) == cpHostContents {
  245. c.Errorf("output matched host file -- symlink path component can escape container rootfs")
  246. }
  247. if string(test) != cpContainerContents {
  248. c.Errorf("output doesn't match the input for symlink path component")
  249. }
  250. }
  251. // Check that cp with unprivileged user doesn't return any error
  252. func (s *DockerSuite) TestCpUnprivilegedUser(c *check.C) {
  253. testRequires(c, UnixCli) // uses chmod/su: not available on windows
  254. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName)
  255. if exitCode != 0 {
  256. c.Fatal("failed to create a container", out)
  257. }
  258. cleanedContainerID := strings.TrimSpace(out)
  259. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  260. if strings.TrimSpace(out) != "0" {
  261. c.Fatal("failed to set up container", out)
  262. }
  263. tmpdir, err := ioutil.TempDir("", "docker-integration")
  264. if err != nil {
  265. c.Fatal(err)
  266. }
  267. defer os.RemoveAll(tmpdir)
  268. if err = os.Chmod(tmpdir, 0777); err != nil {
  269. c.Fatal(err)
  270. }
  271. path := cpTestName
  272. _, _, err = runCommandWithOutput(exec.Command("su", "unprivilegeduser", "-c", dockerBinary+" cp "+cleanedContainerID+":"+path+" "+tmpdir))
  273. if err != nil {
  274. c.Fatalf("couldn't copy with unprivileged user: %s:%s %s", cleanedContainerID, path, err)
  275. }
  276. }
  277. func (s *DockerSuite) TestCpSpecialFiles(c *check.C) {
  278. testRequires(c, SameHostDaemon)
  279. outDir, err := ioutil.TempDir("", "cp-test-special-files")
  280. if err != nil {
  281. c.Fatal(err)
  282. }
  283. defer os.RemoveAll(outDir)
  284. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "touch /foo")
  285. if exitCode != 0 {
  286. c.Fatal("failed to create a container", out)
  287. }
  288. cleanedContainerID := strings.TrimSpace(out)
  289. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  290. if strings.TrimSpace(out) != "0" {
  291. c.Fatal("failed to set up container", out)
  292. }
  293. // Copy actual /etc/resolv.conf
  294. dockerCmd(c, "cp", cleanedContainerID+":/etc/resolv.conf", outDir)
  295. expected, err := ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/resolv.conf")
  296. actual, err := ioutil.ReadFile(outDir + "/resolv.conf")
  297. if !bytes.Equal(actual, expected) {
  298. c.Fatalf("Expected copied file to be duplicate of the container resolvconf")
  299. }
  300. // Copy actual /etc/hosts
  301. dockerCmd(c, "cp", cleanedContainerID+":/etc/hosts", outDir)
  302. expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hosts")
  303. actual, err = ioutil.ReadFile(outDir + "/hosts")
  304. if !bytes.Equal(actual, expected) {
  305. c.Fatalf("Expected copied file to be duplicate of the container hosts")
  306. }
  307. // Copy actual /etc/resolv.conf
  308. dockerCmd(c, "cp", cleanedContainerID+":/etc/hostname", outDir)
  309. expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hostname")
  310. actual, err = ioutil.ReadFile(outDir + "/hostname")
  311. if !bytes.Equal(actual, expected) {
  312. c.Fatalf("Expected copied file to be duplicate of the container resolvconf")
  313. }
  314. }
  315. func (s *DockerSuite) TestCpVolumePath(c *check.C) {
  316. testRequires(c, SameHostDaemon)
  317. tmpDir, err := ioutil.TempDir("", "cp-test-volumepath")
  318. if err != nil {
  319. c.Fatal(err)
  320. }
  321. defer os.RemoveAll(tmpDir)
  322. outDir, err := ioutil.TempDir("", "cp-test-volumepath-out")
  323. if err != nil {
  324. c.Fatal(err)
  325. }
  326. defer os.RemoveAll(outDir)
  327. _, err = os.Create(tmpDir + "/test")
  328. if err != nil {
  329. c.Fatal(err)
  330. }
  331. out, exitCode := dockerCmd(c, "run", "-d", "-v", "/foo", "-v", tmpDir+"/test:/test", "-v", tmpDir+":/baz", "busybox", "/bin/sh", "-c", "touch /foo/bar")
  332. if exitCode != 0 {
  333. c.Fatal("failed to create a container", out)
  334. }
  335. cleanedContainerID := strings.TrimSpace(out)
  336. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  337. if strings.TrimSpace(out) != "0" {
  338. c.Fatal("failed to set up container", out)
  339. }
  340. // Copy actual volume path
  341. dockerCmd(c, "cp", cleanedContainerID+":/foo", outDir)
  342. stat, err := os.Stat(outDir + "/foo")
  343. if err != nil {
  344. c.Fatal(err)
  345. }
  346. if !stat.IsDir() {
  347. c.Fatal("expected copied content to be dir")
  348. }
  349. stat, err = os.Stat(outDir + "/foo/bar")
  350. if err != nil {
  351. c.Fatal(err)
  352. }
  353. if stat.IsDir() {
  354. c.Fatal("Expected file `bar` to be a file")
  355. }
  356. // Copy file nested in volume
  357. dockerCmd(c, "cp", cleanedContainerID+":/foo/bar", outDir)
  358. stat, err = os.Stat(outDir + "/bar")
  359. if err != nil {
  360. c.Fatal(err)
  361. }
  362. if stat.IsDir() {
  363. c.Fatal("Expected file `bar` to be a file")
  364. }
  365. // Copy Bind-mounted dir
  366. dockerCmd(c, "cp", cleanedContainerID+":/baz", outDir)
  367. stat, err = os.Stat(outDir + "/baz")
  368. if err != nil {
  369. c.Fatal(err)
  370. }
  371. if !stat.IsDir() {
  372. c.Fatal("Expected `baz` to be a dir")
  373. }
  374. // Copy file nested in bind-mounted dir
  375. dockerCmd(c, "cp", cleanedContainerID+":/baz/test", outDir)
  376. fb, err := ioutil.ReadFile(outDir + "/baz/test")
  377. if err != nil {
  378. c.Fatal(err)
  379. }
  380. fb2, err := ioutil.ReadFile(tmpDir + "/test")
  381. if err != nil {
  382. c.Fatal(err)
  383. }
  384. if !bytes.Equal(fb, fb2) {
  385. c.Fatalf("Expected copied file to be duplicate of bind-mounted file")
  386. }
  387. // Copy bind-mounted file
  388. dockerCmd(c, "cp", cleanedContainerID+":/test", outDir)
  389. fb, err = ioutil.ReadFile(outDir + "/test")
  390. if err != nil {
  391. c.Fatal(err)
  392. }
  393. fb2, err = ioutil.ReadFile(tmpDir + "/test")
  394. if err != nil {
  395. c.Fatal(err)
  396. }
  397. if !bytes.Equal(fb, fb2) {
  398. c.Fatalf("Expected copied file to be duplicate of bind-mounted file")
  399. }
  400. }
  401. func (s *DockerSuite) TestCpToDot(c *check.C) {
  402. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
  403. if exitCode != 0 {
  404. c.Fatal("failed to create a container", out)
  405. }
  406. cleanedContainerID := strings.TrimSpace(out)
  407. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  408. if strings.TrimSpace(out) != "0" {
  409. c.Fatal("failed to set up container", out)
  410. }
  411. tmpdir, err := ioutil.TempDir("", "docker-integration")
  412. if err != nil {
  413. c.Fatal(err)
  414. }
  415. defer os.RemoveAll(tmpdir)
  416. cwd, err := os.Getwd()
  417. if err != nil {
  418. c.Fatal(err)
  419. }
  420. defer os.Chdir(cwd)
  421. if err := os.Chdir(tmpdir); err != nil {
  422. c.Fatal(err)
  423. }
  424. dockerCmd(c, "cp", cleanedContainerID+":/test", ".")
  425. content, err := ioutil.ReadFile("./test")
  426. if string(content) != "lololol\n" {
  427. c.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n")
  428. }
  429. }
  430. func (s *DockerSuite) TestCpToStdout(c *check.C) {
  431. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test")
  432. if exitCode != 0 {
  433. c.Fatalf("failed to create a container:%s\n", out)
  434. }
  435. cID := strings.TrimSpace(out)
  436. out, _ = dockerCmd(c, "wait", cID)
  437. if strings.TrimSpace(out) != "0" {
  438. c.Fatalf("failed to set up container:%s\n", out)
  439. }
  440. out, _, err := runCommandPipelineWithOutput(
  441. exec.Command(dockerBinary, "cp", cID+":/test", "-"),
  442. exec.Command("tar", "-vtf", "-"))
  443. if err != nil {
  444. c.Fatalf("Failed to run commands: %s", err)
  445. }
  446. if !strings.Contains(out, "test") || !strings.Contains(out, "-rw") {
  447. c.Fatalf("Missing file from tar TOC:\n%s", out)
  448. }
  449. }
  450. func (s *DockerSuite) TestCpNameHasColon(c *check.C) {
  451. testRequires(c, SameHostDaemon)
  452. out, exitCode := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t")
  453. if exitCode != 0 {
  454. c.Fatal("failed to create a container", out)
  455. }
  456. cleanedContainerID := strings.TrimSpace(out)
  457. out, _ = dockerCmd(c, "wait", cleanedContainerID)
  458. if strings.TrimSpace(out) != "0" {
  459. c.Fatal("failed to set up container", out)
  460. }
  461. tmpdir, err := ioutil.TempDir("", "docker-integration")
  462. if err != nil {
  463. c.Fatal(err)
  464. }
  465. defer os.RemoveAll(tmpdir)
  466. dockerCmd(c, "cp", cleanedContainerID+":/te:s:t", tmpdir)
  467. content, err := ioutil.ReadFile(tmpdir + "/te:s:t")
  468. if string(content) != "lololol\n" {
  469. c.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n")
  470. }
  471. }
  472. func (s *DockerSuite) TestCopyAndRestart(c *check.C) {
  473. expectedMsg := "hello"
  474. out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", expectedMsg)
  475. id := strings.TrimSpace(string(out))
  476. out, _ = dockerCmd(c, "wait", id)
  477. status := strings.TrimSpace(out)
  478. if status != "0" {
  479. c.Fatalf("container exited with status %s", status)
  480. }
  481. tmpDir, err := ioutil.TempDir("", "test-docker-restart-after-copy-")
  482. if err != nil {
  483. c.Fatalf("unable to make temporary directory: %s", err)
  484. }
  485. defer os.RemoveAll(tmpDir)
  486. dockerCmd(c, "cp", fmt.Sprintf("%s:/etc/issue", id), tmpDir)
  487. out, _ = dockerCmd(c, "start", "-a", id)
  488. msg := strings.TrimSpace(out)
  489. if msg != expectedMsg {
  490. c.Fatalf("expected %q but got %q", expectedMsg, msg)
  491. }
  492. }
  493. func (s *DockerSuite) TestCopyCreatedContainer(c *check.C) {
  494. dockerCmd(c, "create", "--name", "test_cp", "-v", "/test", "busybox")
  495. tmpDir, err := ioutil.TempDir("", "test")
  496. if err != nil {
  497. c.Fatalf("unable to make temporary directory: %s", err)
  498. }
  499. defer os.RemoveAll(tmpDir)
  500. dockerCmd(c, "cp", "test_cp:/bin/sh", tmpDir)
  501. }