1buildah-copy(1) General Commands Manual buildah-copy(1)
2
3
4
6 buildah-copy - Copies the contents of a file, URL, or directory into a
7 container's working directory.
8
9
11 buildah copy container src [[src ...] dest]
12
13
15 Copies the contents of a file, URL, or a directory to a container's
16 working directory or a specified location in the container. If a local
17 directory is specified as a source, its contents are copied to the des‐
18 tination.
19
20
22 --add-history
23
24
25 Add an entry to the history which will note the digest of the added
26 content. Defaults to false.
27
28
29 Note: You can also override the default value of --add-history by set‐
30 ting the BUILDAH_HISTORY environment variable. export BUILDAH_HIS‐
31 TORY=true
32
33
34 --chmod permissions
35
36
37 Sets the access permissions of the destination content. Accepts the nu‐
38 merical format.
39
40
41 --chown owner:group
42
43
44 Sets the user and group ownership of the destination content.
45
46
47 --contextdir directory
48
49
50 Build context directory. Specifying a context directory causes Buildah
51 to chroot into the context directory. This means copying files pointed
52 at by symbolic links outside of the chroot will fail.
53
54
55 --from containerOrImage
56
57
58 Use the root directory of the specified working container or image as
59 the root directory when resolving absolute source paths and the path of
60 the context directory. If an image needs to be pulled, options recog‐
61 nized by buildah pull can be used.
62
63
64 --ignorefile file
65
66
67 Path to an alternative .containerignore (.dockerignore) file. Requires
68 --contextdir be specified.
69
70
71 --quiet, -q
72
73
74 Refrain from printing a digest of the copied content.
75
76
77 --retry attempts
78
79
80 Number of times to retry in case of failure when performing pull of im‐
81 ages from registry.
82
83
84 Defaults to 3.
85
86
87 --retry-delay duration
88
89
90 Duration of delay between retry attempts in case of failure when per‐
91 forming pull of images from registry.
92
93
94 Defaults to 2s.
95
96
98 buildah copy containerID '/myapp/app.conf' '/myapp/app.conf'
99
100
101 buildah copy --chown myuser:mygroup containerID '/myapp/app.conf'
102 '/myapp/app.conf'
103
104
105 buildah copy --chmod 660 containerID '/myapp/app.conf'
106 '/myapp/app.conf'
107
108
109 buildah copy containerID '/home/myuser/myproject.go'
110
111
112 buildah copy containerID '/home/myuser/myfiles.tar' '/tmp'
113
114
115 buildah copy containerID '/tmp/workingdir' '/tmp/workingdir'
116
117
118 buildah copy containerID 'https://github.com/containers/buildah' '/tmp'
119
120
121 buildah copy containerID 'passwd' 'certs.d' /etc
122
123
125 .containerignore/.dockerignore
126 If the .containerignore/.dockerignore file exists in the context direc‐
127 tory, buildah copy reads its contents. If both exist, then .container‐
128 ignore is used.
129
130
131 When the \fB\fC--ignorefile\fR option is specified Buildah reads it and
132 uses it to decide which content to exclude when copying content into
133 the working container.
134
135
136 Users can specify a series of Unix shell glob patterns in an ignore
137 file to identify files/directories to exclude.
138
139
140 Buildah supports a special wildcard string ** which matches any number
141 of directories (including zero). For example, */.go will exclude all
142 files that end with .go that are found in all directories.
143
144
145 Example .containerignore/.dockerignore file:
146
147
148 # here are files we want to exclude
149 */*.c
150 **/output*
151 src
152
153
154
155 */*.c Excludes files and directories whose names end with .c in any top
156 level subdirectory. For example, the source file include/rootless.c.
157
158
159 **/output* Excludes files and directories starting with output from any
160 directory.
161
162
163 src Excludes files named src and the directory src as well as any con‐
164 tent in it.
165
166
167 Lines starting with ! (exclamation mark) can be used to make exceptions
168 to exclusions. The following is an example .containerignore/.dockerig‐
169 nore file that uses this mechanism:
170
171
172 *.doc
173 !Help.doc
174
175
176
177 Exclude all doc files except Help.doc when copying content into the
178 container.
179
180
181 This functionality is compatible with the handling of .containerignore
182 files described here:
183
184
185 https://github.com/containers/buildah/blob/main/docs/containerig‐
186 nore.5.md
187
188
190 buildah(1), containerignore(5)
191
192
193
194buildah April 2021 buildah-copy(1)