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 [options] [container:]src_path [container:]dest_path
12
13
14       podman    container    cp    [options]    [container:]src_path    [con‐
15       tainer:]dest_path
16
17

DESCRIPTION

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

OPTIONS

93       --extract
94
95
96       Extract the tar file into the destination directory. If the destination
97       directory is not provided, extract the tar file into  the  root  direc‐
98       tory.
99
100
101       --pause
102
103
104       Pause  the  container while copying into it to avoid potential security
105       issues around symlinks. Defaults to true. On rootless  containers  with
106       cgroups V1, defaults to false.
107
108

ALTERNATIVES

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

EXAMPLE

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

SEE ALSO

182       podman(1), podman-mount(1), podman-umount(1)
183
184
185
186                                                                podman-cp(1)()
Impressum