1podman-cp(1)()                                                  podman-cp(1)()
2
3
4

NAME

6       podman-cp  -  Copy  files/folders  between  a  container  and the local
7       filesystem
8
9

SYNOPSIS

11       podman cp [container:]src_path [container:]dest_path
12
13
14       podman container cp [container:]src_path [container:]dest_path
15
16

DESCRIPTION

18       Copy the contents of src_path to the dest_path. You can copy  from  the
19       container's  filesystem  to  the local machine or the reverse, from the
20       local filesystem to the container.  If - is specified  for  either  the
21       SRC_PATH  or DEST_PATH, you can also stream a tar archive from STDIN or
22       to STDOUT.
23
24
25       The CONTAINER can be a running or stopped container.  The  src_path  or
26       dest_path can be a file or directory.
27
28
29       The  podman cp command assumes container paths are relative to the con‐
30       tainer's root directory (i.e., /).
31
32
33       This means supplying the initial forward slash is optional;
34
35
36       The command sees compassionate_darwin:/tmp/foo/myfile.txt  and  compas‐
37       sionate_darwin:tmp/foo/myfile.txt as identical.
38
39
40       Local  machine paths can be an absolute or relative value.  The command
41       interprets a local machine's relative paths as relative to the  current
42       working directory where podman cp is run.
43
44
45       Assuming a path separator of /, a first argument of src_path and second
46       argument of dest_path, the behavior is as follows:
47
48
49       src_path specifies a file
50         - dest_path does not exist
51           - the file is saved to a file created at dest_path (note that  par‐
52       ent directory must exist)
53         - dest_path exists and is a file
54           - the destination is overwritten with the source file's contents
55         - dest_path exists and is a directory
56           -  the  file is copied into this directory using the base name from
57       src_path
58
59
60       src_path specifies a directory
61         - dest_path does not exist
62           - dest_path is created as a  directory  and  the  contents  of  the
63       source directory are copied into this directory
64         - dest_path exists and is a file
65           - Error condition: cannot copy a directory to a file
66         - dest_path exists and is a directory
67           - src_path ends with /
68             - the source directory is copied into this directory
69           - src_path ends with /. (i.e., slash followed by dot)
70             -  the content of the source directory is copied into this direc‐
71       tory
72
73
74       The command requires src_path and dest_path to exist according  to  the
75       above rules.
76
77
78       If  src_path  is  local and is a symbolic link, the symbolic target, is
79       copied by default.
80
81
82       A colon (:) is used as a delimiter between CONTAINER and its path.
83
84
85       You can also use : when specifying paths to a src_path or dest_path  on
86       a local machine, for example, file:name.txt.
87
88
89       If  you  use  a  : in a local machine path, you must be explicit with a
90       relative or absolute path, for example:      /path/to/file:name.txt  or
91       ./file:name.txt
92
93
94       Using - as the src_path streams the contents of STDIN as a tar archive.
95       The command extracts the content of the tar to  the  DEST_PATH  in  the
96       container. In this case, dest_path must specify a directory. Using - as
97       the dest_path streams the contents of the resource (can be a directory)
98       as a tar archive to STDOUT.
99
100
101       Note  that podman cp ignores permission errors when copying from a run‐
102       ning rootless container.  The TTY devices inside a  rootless  container
103       are  owned  by the host's root user and hence cannot be read inside the
104       container's user namespace.
105
106

OPTIONS

ALTERNATIVES

109       Podman has much stronger capabilities than just podman  cp  to  achieve
110       copy files between host and container.
111
112
113       Using  standard  podman-mount  and podman-umount takes advantage of the
114       entire linux tool chain, rather then just cp.
115
116
117       If a user wants to copy contents out of a  container  or  into  a  con‐
118       tainer, they can execute a few simple commands.
119
120
121       You  can  copy from the container's file system to the local machine or
122       the reverse, from the local filesystem to the container.
123
124
125       If you want to copy the /etc/foobar directory out of  a  container  and
126       onto /tmp on the host, you could execute the following commands:
127
128
129              mnt=$(podman mount CONTAINERID)
130              cp -R ${mnt}/etc/foobar /tmp
131              podman umount CONTAINERID
132
133
134
135       If you want to untar a tar ball into a container, you can execute these
136       commands:
137
138
139              mnt=$(podman mount CONTAINERID)
140              tar xf content.tgz -C ${mnt}
141              podman umount CONTAINERID
142
143
144
145       One last example, if you want to install a  package  into  a  container
146       that does not have dnf installed, you could execute something like:
147
148
149              mnt=$(podman mount CONTAINERID)
150              dnf install --installroot=${mnt} httpd
151              chroot ${mnt} rm -rf /var/log/dnf /var/cache/dnf
152              podman umount CONTAINERID
153
154
155
156       This shows that using podman mount and podman umount you can use all of
157       the standard linux tools for moving files into and out  of  containers,
158       not just the cp command.
159
160

EXAMPLE

162       podman cp /myapp/app.conf containerID:/myapp/app.conf
163
164
165       podman cp /home/myuser/myfiles.tar containerID:/tmp
166
167
168       podman cp containerID:/myapp/ /myapp/
169
170
171       podman cp containerID:/home/myuser/. /home/myuser/
172
173
174       podman cp - containerID:/myfiles.tar.gz < myfiles.tar.gz
175
176

SEE ALSO

178       podman(1), podman-mount(1), podman-umount(1)
179
180
181
182                                                                podman-cp(1)()
Impressum