diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index 5231066a2e..faeb7bd96e 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -382,6 +382,8 @@ func copyToContainer(container string, containerPath string, hostPath string) er if err != nil { return err } + defer os.Remove(tmpFile.Name()) + _, err = io.Copy(tmpFile, os.Stdin) if err != nil { return err @@ -389,6 +391,7 @@ func copyToContainer(container string, containerPath string, hostPath string) er if err = tmpFile.Close(); err != nil { return err } + if !archive.IsArchivePath(tmpFile.Name()) { return errors.New("source must be a (compressed) tar archive when copying from stdin") }