2018-03-20 17:41:19 +08:00
|
|
|
# buildah-add "1" "March 2017" "buildah"
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
## NAME
|
2018-04-26 21:01:15 +08:00
|
|
|
buildah\-add - Add the contents of a file, URL, or a directory to a container.
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
## SYNOPSIS
|
2018-06-30 03:39:36 +08:00
|
|
|
**buildah add** [*options*] *container* *src* [[*src* ...] *dest*]
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
## DESCRIPTION
|
2017-04-14 03:42:04 +08:00
|
|
|
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.
|
2017-03-29 03:37:24 +08:00
|
|
|
|
2017-11-30 22:34:02 +08:00
|
|
|
## OPTIONS
|
|
|
|
|
2019-01-19 04:39:58 +08:00
|
|
|
**--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`
|
|
|
|
|
2017-11-30 22:34:02 +08:00
|
|
|
**--chown** *owner*:*group*
|
|
|
|
|
|
|
|
Sets the user and group ownership of the destination content.
|
|
|
|
|
2018-06-08 22:52:52 +08:00
|
|
|
**--quiet**
|
|
|
|
|
|
|
|
Refrain from printing a digest of the added content.
|
|
|
|
|
2017-03-29 03:37:24 +08:00
|
|
|
## EXAMPLE
|
2017-04-14 03:42:04 +08:00
|
|
|
|
|
|
|
buildah add containerID '/myapp/app.conf' '/myapp/app.conf'
|
|
|
|
|
2017-11-30 22:34:02 +08:00
|
|
|
buildah add --chown myuser:mygroup containerID '/myapp/app.conf' '/myapp/app.conf'
|
|
|
|
|
2017-04-14 03:42:04 +08:00
|
|
|
buildah add containerID '/home/myuser/myproject.go'
|
|
|
|
|
|
|
|
buildah add containerID '/home/myuser/myfiles.tar' '/tmp'
|
|
|
|
|
|
|
|
buildah add containerID '/tmp/workingdir' '/tmp/workingdir'
|
|
|
|
|
2018-09-18 03:20:16 +08:00
|
|
|
buildah add containerID 'https://github.com/containers/buildah/blob/master/README.md' '/tmp'
|
2017-04-14 03:42:04 +08:00
|
|
|
|
|
|
|
buildah add containerID 'passwd' 'certs.d' /etc
|
2017-03-29 03:37:24 +08:00
|
|
|
|
2020-08-05 01:54:08 +08:00
|
|
|
## FILES
|
|
|
|
|
|
|
|
### `.dockerignore`
|
|
|
|
|
|
|
|
If the file .dockerignore exists in the context directory, `buildah copy` reads
|
|
|
|
its contents. Buildah uses the content to exclude files and directories from
|
|
|
|
the context directory, when copying content into the image.
|
|
|
|
|
|
|
|
Users can specify a series of Unix shell globals in a .dockerignore file to
|
2020-08-07 16:59:27 +08:00
|
|
|
identify files/directories to exclude.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
```
|
2020-08-07 16:59:27 +08:00
|
|
|
# here are files we want to exclude
|
|
|
|
*/*.c
|
|
|
|
**/output*
|
|
|
|
src
|
2020-08-05 01:54:08 +08:00
|
|
|
```
|
|
|
|
|
2020-08-07 16:59:27 +08:00
|
|
|
`*/*.c`
|
|
|
|
Excludes files and directories whose names ends with .c in any top level subdirectory. For example, the source file include/rootless.c.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2020-08-07 16:59:27 +08:00
|
|
|
`**/output*`
|
|
|
|
Excludes files and directories starting with `output` from any directory.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2020-08-07 16:59:27 +08:00
|
|
|
`src`
|
|
|
|
Excludes files named src and the directory src as well as any content in it.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
|
|
|
Lines starting with ! (exclamation mark) can be used to make exceptions to
|
|
|
|
exclusions. The following is an example .dockerignore file that uses this
|
|
|
|
mechanism:
|
|
|
|
```
|
2020-08-07 16:59:27 +08:00
|
|
|
*.doc
|
|
|
|
!Help.doc
|
2020-08-05 01:54:08 +08:00
|
|
|
```
|
|
|
|
|
2020-08-07 16:59:27 +08:00
|
|
|
Exclude all doc files except Help.doc from the image.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2020-08-07 16:59:27 +08:00
|
|
|
This functionality is compatible with the handling of .dockerignore files described here:
|
2020-08-05 01:54:08 +08:00
|
|
|
|
|
|
|
https://docs.docker.com/engine/reference/builder/#dockerignore-file
|
|
|
|
|
2017-03-29 03:37:24 +08:00
|
|
|
## SEE ALSO
|
|
|
|
buildah(1)
|