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
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
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
79 buildah add containerID '/myapp/app.conf' '/myapp/app.conf'
80
81
82 buildah add --chown myuser:mygroup containerID '/myapp/app.conf'
83 '/myapp/app.conf'
84
85
86 buildah add --chmod 660 containerID '/myapp/app.conf' '/myapp/app.conf'
87
88
89 buildah add containerID '/home/myuser/myproject.go'
90
91
92 buildah add containerID '/home/myuser/myfiles.tar' '/tmp'
93
94
95 buildah add containerID '/tmp/workingdir' '/tmp/workingdir'
96
97
98 buildah add containerID 'https://github.com/containers/buil‐
99 dah/blob/master/README.md' '/tmp'
100
101
102 buildah add containerID 'passwd' 'certs.d' /etc
103
104
106 .containerignore/.dockerignore
107 If the .containerignore/.dockerignore file exists in the context direc‐
108 tory, buildah add reads its contents. If both exist, then .containerig‐
109 nore is used.
110
111
112 When the \fB\fC--ignorefile\fR option is specified Buildah reads it and
113 uses it to decide which content to exclude when copying content into
114 the working container.
115
116
117 Users can specify a series of Unix shell glob patterns in an ignore
118 file to identify files/directories to exclude.
119
120
121 Buildah supports a special wildcard string ** which matches any number
122 of directories (including zero). For example, */.go will exclude all
123 files that end with .go that are found in all directories.
124
125
126 Example .containerignore/.dockerignore file:
127
128
129 # here are files we want to exclude
130 */*.c
131 **/output*
132 src
133
134
135
136 */*.c Excludes files and directories whose names ends with .c in any
137 top level subdirectory. For example, the source file include/root‐
138 less.c.
139
140
141 **/output* Excludes files and directories starting with output from any
142 directory.
143
144
145 src Excludes files named src and the directory src as well as any con‐
146 tent in it.
147
148
149 Lines starting with ! (exclamation mark) can be used to make exceptions
150 to exclusions. The following is an example .containerignore file that
151 uses this mechanism:
152
153
154 *.doc
155 !Help.doc
156
157
158
159 Exclude all doc files except Help.doc when copying content into the
160 container.
161
162
163 This functionality is compatible with the handling of .dockerignore
164 files described here:
165
166
167 https://docs.docker.com/engine/reference/builder/#dockerignore-file
168
169
171 buildah(1)
172
173
174
175buildah April 2021 buildah-add(1)