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
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/main/README.md' '/tmp'
100
101
102 buildah add containerID 'passwd' 'certs.d' /etc
103
104
106 .containerignore
107 If a .containerignore or .dockerignore file exists in the context di‐
108 rectory, buildah add reads its contents. If both exist, then .con‐
109 tainerignore 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 end with .c in any top
137 level subdirectory. For example, the source file include/rootless.c.
138
139
140 **/output* Excludes files and directories starting with output from any
141 directory.
142
143
144 src Excludes files named src and the directory src as well as any con‐
145 tent in it.
146
147
148 Lines starting with ! (exclamation mark) can be used to make exceptions
149 to exclusions. The following is an example .containerignore file that
150 uses this mechanism:
151
152
153 *.doc
154 !Help.doc
155
156
157
158 Exclude all doc files except Help.doc when copying content into the
159 container.
160
161
162 This functionality is compatible with the handling of .containerignore
163 files described here:
164
165
166 https://github.com/containers/buildah/blob/main/docs/containerig‐
167 nore.5.md
168
169
171 buildah(1), containerignore(5)
172
173
174
175buildah April 2021 buildah-add(1)