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