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 basename 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

OPTIONS

ALTERNATIVES

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

EXAMPLE

156       podman cp /myapp/app.conf containerID:/myapp/app.conf
157
158
159       podman cp /home/myuser/myfiles.tar containerID:/tmp
160
161
162       podman cp containerID:/myapp/ /myapp/
163
164
165       podman cp containerID:/home/myuser/. /home/myuser/
166
167
168       podman cp - containerID:/myfiles.tar.gz < myfiles.tar.gz
169
170

SEE ALSO

172       podman(1), podman-mount(1), podman-umount(1)
173
174
175
176                                                                podman-cp(1)()
Impressum