.nh .TH podman\-cp(1) .SH NAME .PP podman\-cp \- Copy files/folders between a container and the local filesystem .SH SYNOPSIS .PP \fBpodman cp\fP [\fIcontainer\fP:]\fIsrc\_path\fP [\fIcontainer\fP:]\fIdest\_path\fP .PP \fBpodman container cp\fP [\fIcontainer\fP:]\fIsrc\_path\fP [\fIcontainer\fP:]\fIdest\_path\fP .SH DESCRIPTION .PP Copy the contents of \fBsrc\_path\fP to the \fBdest\_path\fP\&. You can copy from the container's filesystem to the local machine or the reverse, from the local filesystem to the container. If \fB\fC\-\fR is specified for either the SRC\_PATH or DEST\_PATH, you can also stream a tar archive from STDIN or to STDOUT. .PP The CONTAINER can be a running or stopped container. The \fBsrc\_path\fP or \fBdest\_path\fP can be a file or directory. .PP The \fBpodman cp\fP command assumes container paths are relative to the container's root directory (i.e., \fB\fC/\fR). .PP This means supplying the initial forward slash is optional; .PP The command sees \fBcompassionate\_darwin:/tmp/foo/myfile.txt\fP and \fBcompassionate\_darwin:tmp/foo/myfile.txt\fP as identical. .PP Local machine paths can be an absolute or relative value. The command interprets a local machine's relative paths as relative to the current working directory where \fBpodman cp\fP is run. .PP Assuming a path separator of /, a first argument of \fBsrc\_path\fP and second argument of \fBdest\_path\fP, the behavior is as follows: .PP \fBsrc\_path\fP specifies a file \- \fBdest\_path\fP does not exist \- the file is saved to a file created at \fBdest\_path\fP (note that parent directory must exist) \- \fBdest\_path\fP exists and is a file \- the destination is overwritten with the source file's contents \- \fBdest\_path\fP exists and is a directory \- the file is copied into this directory using the basename from \fBsrc\_path\fP .PP \fBsrc\_path\fP specifies a directory \- \fBdest\_path\fP does not exist \- \fBdest\_path\fP is created as a directory and the contents of the source directory are copied into this directory \- \fBdest\_path\fP exists and is a file \- Error condition: cannot copy a directory to a file \- \fBdest\_path\fP exists and is a directory \- \fBsrc\_path\fP ends with \fB\fC/\fR \- the source directory is copied into this directory \- \fBsrc\_path\fP ends with \fB\fC/.\fR (i.e., slash followed by dot) \- the content of the source directory is copied into this directory .PP The command requires \fBsrc\_path\fP and \fBdest\_path\fP to exist according to the above rules. .PP If \fBsrc\_path\fP is local and is a symbolic link, the symbolic target, is copied by default. .PP A colon (:) is used as a delimiter between CONTAINER and its path. .PP You can also use : when specifying paths to a \fBsrc\_path\fP or \fBdest\_path\fP on a local machine, for example, \fB\fCfile:name.txt\fR\&. .PP If you use a : in a local machine path, you must be explicit with a relative or absolute path, for example: \fB\fC/path/to/file:name.txt\fR or \fB\fC\&./file:name.txt\fR .PP Using \fB\fC\-\fR as the \fIsrc\_path\fP streams the contents of STDIN as a tar archive. The command extracts the content of the tar to the \fIDEST\_PATH\fP in the container. In this case, \fIdest\_path\fP must specify a directory. Using \fB\fC\-\fR as the \fIdest\_path\fP streams the contents of the resource (can be a directory) as a tar archive to STDOUT. .SH OPTIONS .SH ALTERNATIVES .PP Podman has much stronger capabilities than just \fB\fCpodman cp\fR to achieve copy files between host and container. .PP Using standard podman\-mount and podman\-umount takes advantage of the entire linux tool chain, rather then just cp. .PP If a user wants to copy contents out of a container or into a container, they can execute a few simple commands. .PP You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container. .PP If you want to copy the /etc/foobar directory out of a container and onto /tmp on the host, you could execute the following commands: .PP .RS .nf mnt=$(podman mount CONTAINERID) cp \-R ${mnt}/etc/foobar /tmp podman umount CONTAINERID .fi .RE .PP If you want to untar a tar ball into a container, you can execute these commands: .PP .RS .nf mnt=$(podman mount CONTAINERID) tar xf content.tgz \-C ${mnt} podman umount CONTAINERID .fi .RE .PP One last example, if you want to install a package into a container that does not have dnf installed, you could execute something like: .PP .RS .nf mnt=$(podman mount CONTAINERID) dnf install \-\-installroot=${mnt} httpd chroot ${mnt} rm \-rf /var/log/dnf /var/cache/dnf podman umount CONTAINERID .fi .RE .PP This shows that using \fB\fCpodman mount\fR and \fB\fCpodman umount\fR you can use all of the standard linux tools for moving files into and out of containers, not just the cp command. .SH EXAMPLE .PP podman cp /myapp/app.conf containerID:/myapp/app.conf .PP podman cp /home/myuser/myfiles.tar containerID:/tmp .PP podman cp containerID:/myapp/ /myapp/ .PP podman cp containerID:/home/myuser/. /home/myuser/ .PP podman cp \- containerID:/myfiles.tar.gz < myfiles.tar.gz .SH SEE ALSO .PP podman(1), podman\-mount(1), podman\-umount(1)