2021-04-07 05:48:25 +08:00
|
|
|
# buildah-copy "1" "April 2021" "buildah"
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
|
## NAME
|
2018-04-26 21:01:15 +08:00
|
|
|
buildah\-copy - Copies the contents of a file, URL, or directory into a container's working directory.
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
|
## SYNOPSIS
|
2018-06-30 03:39:36 +08:00
|
|
|
**buildah copy** *container* *src* [[*src* ...] *dest*]
|
2017-03-29 03:37:24 +08:00
|
|
|
|
|
|
|
|
## DESCRIPTION
|
2017-04-14 03:42:04 +08:00
|
|
|
Copies 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 directory is
|
|
|
|
|
specified as a source, its *contents* are copied to the destination.
|
|
|
|
|
|
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`
|
|
|
|
|
|
2021-02-24 07:14:04 +08:00
|
|
|
**--chmod** *permissions*
|
|
|
|
|
|
|
|
|
|
Sets the access permissions of the destination content. Accepts the numerical format.
|
|
|
|
|
|
2017-11-30 22:34:02 +08:00
|
|
|
**--chown** *owner*:*group*
|
|
|
|
|
|
|
|
|
|
Sets the user and group ownership of the destination content.
|
|
|
|
|
|
2021-06-18 18:50:37 +08:00
|
|
|
**--contextdir** *directory*
|
2020-11-19 21:14:58 +08:00
|
|
|
|
|
|
|
|
Build context directory. Specifying a context directory causes Buildah to
|
|
|
|
|
chroot into a the context directory. This means copying files pointed at
|
|
|
|
|
by symbolic links outside of the chroot will fail.
|
|
|
|
|
|
2021-04-07 05:48:25 +08:00
|
|
|
**--from** *containerOrImage*
|
|
|
|
|
|
|
|
|
|
Use the root directory of the specified working container or image as the root
|
|
|
|
|
directory when resolving absolute source paths and the path of the context
|
|
|
|
|
directory. If an image needs to be pulled, options recognized by `buildah pull`
|
|
|
|
|
can be used.
|
|
|
|
|
|
2021-06-18 18:50:37 +08:00
|
|
|
**--ignorefile** *file*
|
2020-11-19 21:14:58 +08:00
|
|
|
|
2021-03-13 19:41:15 +08:00
|
|
|
Path to an alternative .containerignore (.dockerignore) file. Requires \-\-contextdir be specified.
|
2020-11-19 21:14:58 +08:00
|
|
|
|
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**
|
2018-06-08 22:52:52 +08:00
|
|
|
|
|
|
|
|
Refrain from printing a digest of the copied content.
|
|
|
|
|
|
2017-04-14 03:42:04 +08:00
|
|
|
## EXAMPLE
|
2017-03-29 03:37:24 +08:00
|
|
|
|
2017-04-14 03:42:04 +08:00
|
|
|
buildah copy containerID '/myapp/app.conf' '/myapp/app.conf'
|
2017-03-29 03:37:24 +08:00
|
|
|
|
2017-11-30 22:34:02 +08:00
|
|
|
buildah copy --chown myuser:mygroup containerID '/myapp/app.conf' '/myapp/app.conf'
|
|
|
|
|
|
2021-02-27 07:41:30 +08:00
|
|
|
buildah copy --chmod 660 containerID '/myapp/app.conf' '/myapp/app.conf'
|
|
|
|
|
|
2017-04-14 03:42:04 +08:00
|
|
|
buildah copy containerID '/home/myuser/myproject.go'
|
2017-03-29 03:37:24 +08:00
|
|
|
|
2017-04-14 03:42:04 +08:00
|
|
|
buildah copy containerID '/home/myuser/myfiles.tar' '/tmp'
|
|
|
|
|
|
|
|
|
|
buildah copy containerID '/tmp/workingdir' '/tmp/workingdir'
|
|
|
|
|
|
2018-09-18 03:20:16 +08:00
|
|
|
buildah copy containerID 'https://github.com/containers/buildah' '/tmp'
|
2017-04-14 03:42:04 +08:00
|
|
|
|
|
|
|
|
buildah copy containerID 'passwd' 'certs.d' /etc
|
2017-03-29 03:37:24 +08:00
|
|
|
|
2020-08-05 01:54:08 +08:00
|
|
|
## FILES
|
|
|
|
|
|
2021-03-13 19:41:15 +08:00
|
|
|
### .containerignore/.dockerignore
|
|
|
|
|
|
|
|
|
|
If the .containerignore/.dockerignore file exists in the context directory,
|
|
|
|
|
`buildah copy` reads its contents. If both exist, then .containerignore is used.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2021-04-07 05:48:25 +08:00
|
|
|
When the \fB\fC\-\-ignorefile\fR option is specified Buildah reads it and
|
|
|
|
|
uses it to decide which content to exclude when copying content into the
|
|
|
|
|
working container.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2021-04-07 05:48:25 +08:00
|
|
|
Users can specify a series of Unix shell glob patterns in an ignore 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.
|
|
|
|
|
|
2021-03-13 19:41:15 +08:00
|
|
|
Example .containerignore/.dockerignore file:
|
2020-08-05 01:54:08 +08:00
|
|
|
|
|
|
|
|
```
|
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
|
2021-03-13 19:41:15 +08:00
|
|
|
exclusions. The following is an example .containerignore/.dockerignore file that uses this
|
2020-08-05 01:54:08 +08:00
|
|
|
mechanism:
|
|
|
|
|
```
|
2020-08-07 16:59:27 +08:00
|
|
|
*.doc
|
|
|
|
|
!Help.doc
|
2020-08-05 01:54:08 +08:00
|
|
|
```
|
|
|
|
|
|
2021-04-07 05:48:25 +08:00
|
|
|
Exclude all doc files except Help.doc when copying content into the container.
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2021-10-09 20:26:55 +08:00
|
|
|
This functionality is compatible with the handling of .containerignore files described here:
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2021-10-09 20:26:55 +08:00
|
|
|
https://github.com/containers/buildah/blob/main/docs/containerignore.5.md
|
2020-08-05 01:54:08 +08:00
|
|
|
|
2017-03-29 03:37:24 +08:00
|
|
|
## SEE ALSO
|
2021-10-09 20:26:55 +08:00
|
|
|
buildah(1), containerignore(5)
|