buildah/docs/buildah-add.md

109 lines
3.1 KiB
Markdown
Raw Normal View History

# buildah-add "1" "March 2017" "buildah"
## NAME
buildah\-add - Add the contents of a file, URL, or a directory to a container.
## SYNOPSIS
**buildah add** [*options*] *container* *src* [[*src* ...] *dest*]
## DESCRIPTION
Adds the contents of a file, URL, or a directory to a container's working
directory or a specified location in the container. If a local source file
appears to be an archive, its contents are extracted and added instead of the
archive file itself. If a local directory is specified as a source, its
*contents* are copied to the destination.
## OPTIONS
**--add-history**
Add an entry to the history which will note the digest of the added content.
Defaults to false.
Note: You can also override the default value of --add-history by setting the
BUILDAH\_HISTORY environment variable. `export BUILDAH_HISTORY=true`
**--chown** *owner*:*group*
Sets the user and group ownership of the destination content.
**--contextdir**
Build context directory. Specifying a context directory causes Buildah to
chroot into that context directory. This means copying files pointed at
by symbolic links outside of the chroot will fail.
**--ignorefile**
Path to an alternative .dockerignore file. Requires --contextdir be specified.
New CI check: xref --help vs man pages Run 'buildah --help', recursively against all subcommands, then cross-reference the results against docs/buildah*.md. Report differences in subcommands and/or flags. The majority of the changes in this PR are trivial (see below) but a handful may be controversial and require careful review: * Making 'bud' the default output of 'buildah help', with 'build-using-dockerfile' as an alias. This is the inverse of the situation until now: buildah would list build-using-dockerfile as the primary name. The man page, OTOH, lists 'bud'. The source file name is 'bud'. I suspect that most people type 'bud'. So, for consistency, I choose to make 'bud' the default visible command. * add --encryption-key and --encrypt-layer documentation to buildah-commit.md, and --encrypt-layer to -push.md. Please double-check the wording here. * remove --notruncate from buildah-images.md. The option does not exist (although there is a TODO comment in the code). If it should exist, it is left to the reader to implement. I would humbly suggest that this is a good idea, for consistency with buildah containers. * remove --shm-size from buildah-pull.md. The option does not exist, and I suspect this was a copy-paste error. * remove --security-opt from run.go. It was unimplemented and undocumented. * remove --userns-[gu]id-map from buildah-bud.md. These are global options, not bud options, and are documented well enough in buildah.bud. Trivial (IMO) changes: * split options in man pages, from '**--foo, -f**' to '**--foo**, **-f**'. This conforms with the style used in podman man pages. * add missing one-letter aliases (usually "-q", "-a") * add missing man page entries for some easy options * sort out-of-order subcommand listings in man pages Finally, do note that this is a copy-and-alter duplicate of the original script in podman, and that is horrible. In an ideal world I would've been able to refactor the podman version into something usable on both repos (and then more). It turns out the differences in man page format and in special-case handling are too broad to let me do a clean refactor. Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-21 22:51:19 +08:00
**--quiet**, **-q**
Refrain from printing a digest of the added content.
## EXAMPLE
buildah add containerID '/myapp/app.conf' '/myapp/app.conf'
buildah add --chown myuser:mygroup containerID '/myapp/app.conf' '/myapp/app.conf'
buildah add containerID '/home/myuser/myproject.go'
buildah add containerID '/home/myuser/myfiles.tar' '/tmp'
buildah add containerID '/tmp/workingdir' '/tmp/workingdir'
buildah add containerID 'https://github.com/containers/buildah/blob/master/README.md' '/tmp'
buildah add containerID 'passwd' 'certs.d' /etc
## FILES
### .dockerignore
When the \fB\fC\-\-ignorefile\fR option is specified Buildah reads the
content to exclude files and directories from the source directory, when
copying content into the image.
Users can specify a series of Unix shell globals in a ignore file to
identify files/directories to exclude.
Buildah supports a special wildcard string `**` which matches any number of
directories (including zero). For example, **/*.go will exclude all files that
end with .go that are found in all directories.
Example .dockerignore file:
```
# here are files we want to exclude
*/*.c
**/output*
src
```
`*/*.c`
Excludes files and directories whose names ends with .c in any top level subdirectory. For example, the source file include/rootless.c.
`**/output*`
Excludes files and directories starting with `output` from any directory.
`src`
Excludes files named src and the directory src as well as any content in it.
Lines starting with ! (exclamation mark) can be used to make exceptions to
exclusions. The following is an example .dockerignore file that uses this
mechanism:
```
*.doc
!Help.doc
```
Exclude all doc files except Help.doc from the image.
This functionality is compatible with the handling of .dockerignore files described here:
https://docs.docker.com/engine/reference/builder/#dockerignore-file
## SEE ALSO
buildah(1)