Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman cp cont:/tmp/foo.bar baz" always tries to create a new directory #3460

Closed
jwakely opened this issue Jul 1, 2019 · 5 comments
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@jwakely
Copy link
Contributor

jwakely commented Jul 1, 2019

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

When using podman cp to copy a file from a container to the local machine, the file is always created in a new directory, contrary to the documented behaviour.

Steps to reproduce the issue:

$ cat > Dockerfile <<EOT
FROM ubuntu:16.04
RUN touch /tmp/foo.bar
EOT
$ podman build -t image  .
STEP 1: FROM ubuntu:16.04
STEP 2: RUN touch /tmp/foo.bar
STEP 3: COMMIT image
ea3a4fc42378e32c927dc171c7916a72d696ae88a2bf64f206546c77b49a4d2b
$ podman create --name cont image
a6d72c9bbcd64830350e087bc5abe2f46fc768f576534aa65e28d272f7cf9562
$ podman cp cont:/tmp/foo.bar .
$ ls -l
total 4
-rw-rw-r--. 1 jwakely jwakely 41 Jul  1 11:11 Dockerfile
drwx------. 2 jwakely jwakely 60 Jul  1 11:11 foo.bar
$ file foo.bar
foo.bar: directory
$ ls -l ./foo.bar/*
-rw-r--r--. 1 jwakely jwakely 0 Jul  1 11:11 ./foo.bar/foo.bar

Describe the results you received:

A new directory is created with the basename of the source file, and then the file is created in that directory.

Describe the results you expected:

The file should be created as ./foo.bar not ./foo.bar/foo.bar

The behaviour documented in the podman-cp man page is:

Assuming a path separator of /, a first argument of src_path and second argument of dest_path, the behavior is as follows:

src_path specifies a file

  • dest_path does not exist
    • the file is saved to a file created at dest_path
  • dest_path does not exist and ends with /
    • dest_path is created as a directory and the file is copied into this directory using the basename from src_path
  • dest_path exists and is a file
    • the destination is overwritten with the source file's contents
  • dest_path exists and is a directory
    • the file is copied into this directory using the basename from src_path

Additional information you deem important (e.g. issue happens only occasionally):

This is 100% reproducible, and fails to do what the man page says in all cases.

  • dest_path does not exist
    • the file is saved to a file created at dest_path

Nope, it's saved to a directory with that name instead:

$ podman cp cont:/tmp/foo.bar baz
wraith:context$ ls -l
total 4
-rw-rw-r--. 1 jwakely jwakely 41 Jul  1 11:11 Dockerfile
drwx------. 2 jwakely jwakely 60 Jul  1 11:25 baz
drwx------. 2 jwakely jwakely 60 Jul  1 11:11 foo.bar
  • dest_path does not exist and ends with /
    • dest_path is created as a directory and the file is copied into this directory using the basename from src_path

Nope, created into a sub-directory of dest_path:

$ podman cp cont:/tmp/foo.bar newdir/
$ ls -l newdir
total 0
drwx------. 2 jwakely jwakely 60 Jul  1 11:30 foo.bar
  • dest_path exists and is a file
    • the destination is overwritten with the source file's contents

Nope, it tries to create a directory with that name and fails:

$ touch file
$ podman cp cont:/tmp/foo.bar file
Error: error copying "/home/jwakely/.local/share/containers/storage/overlay/309c434bc6a0cd32f20656c5a45005a113a2d84e67e2e0dab3c88daa46ee3bad/merged/tmp/foo.bar" to "/tmp/context/file/foo.bar": mkdir /tmp/context/file: not a directory
  • dest_path exists and is a directory
    • the file is copied into this directory using the basename from src_path

Nope:

$ mkdir dir
$ podman cp cont:/tmp/foo.bar dir
$ ls -l dir
total 0
drwx------. 2 jwakely jwakely 60 Jul  1 11:32 foo.bar

Output of podman version:

Version:            1.4.2
RemoteAPI Version:  1
Go Version:         go1.12.5
OS/Arch:            linux/amd64

Output of podman info --debug:

debug:
  compiler: gc
  git commit: ""
  go version: go1.12.5
  podman version: 1.4.2
host:
  BuildahVersion: 1.9.0
  Conmon:
    package: podman-1.4.2-1.fc30.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 0.2.0, commit: d7234dc01ae2ef08c42e3591e876723ad1c914c9'
  Distribution:
    distribution: fedora
    version: "30"
  MemFree: 12902002688
  MemTotal: 67467558912
  OCIRuntime:
    package: runc-1.0.0-93.dev.gitb9b6cc6.fc30.x86_64
    path: /usr/bin/runc
    version: |-
      runc version 1.0.0-rc8+dev
      commit: e3b4c1108f7d1bf0d09ab612ea09927d9b59b4e3
      spec: 1.0.1-dev
  SwapFree: 64391983104
  SwapTotal: 64409821184
  arch: amd64
  cpus: 8
  hostname: wraith.home
  kernel: 5.1.12-300.fc30.x86_64
  os: linux
  rootless: true
  uptime: 114h 51m 0.16s (Approximately 4.75 days)
registries:
  blocked: null
  insecure: null
  search:
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  ConfigFile: /home/jwakely/.config/containers/storage.conf
  ContainerStore:
    number: 2
  GraphDriverName: overlay
  GraphOptions:
  - overlay.mount_program=/usr/bin/fuse-overlayfs
  GraphRoot: /home/jwakely/.local/share/containers/storage
  GraphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 14
  RunRoot: /tmp/1000
  VolumePath: /home/jwakely/.local/share/containers/storage/volumes

Additional environment details (AWS, VirtualBox, physical, etc.):

Physical box running Fedora 30, with podman installed from Fedora RPM repo.

I think this behaviour started when upgrading from 1.4.0 to 1.4.2, but I could be wrong.

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 1, 2019
@giuseppe
Copy link
Member

giuseppe commented Jul 1, 2019

/cc @QiWang19

@jwakely
Copy link
Contributor Author

jwakely commented Jul 1, 2019

Oh I think this looks like a dup of #3384

@mheon
Copy link
Member

mheon commented Jul 1, 2019 via email

@jwakely
Copy link
Contributor Author

jwakely commented Jul 8, 2019

The bug is fixed in the Fedora podman-1.4.4-1.fc30.x86_64 package:

Version:            1.4.5-dev
RemoteAPI Version:  1
Go Version:         go1.12.6
OS/Arch:            linux/amd64

So I suggest closing it as a dup of #3384. Sorry for the dup.

@mheon mheon closed this as completed Jul 8, 2019
@mheon
Copy link
Member

mheon commented Jul 8, 2019

Closed, thanks for verifying!

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

4 participants