buildah-copy - Copies the contents of a file, URL, or directory into a container's working directory.
Contents
Description
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.
Example
buildah copy containerID '/myapp/app.conf' '/myapp/app.conf'
buildah copy --exclude=*/.md docs containerID 'docs' '/docs'
buildah copy --chown myuser:mygroup containerID '/myapp/app.conf' '/myapp/app.conf'
buildah copy --chmod 660 containerID '/myapp/app.conf' '/myapp/app.conf'
buildah copy containerID '/home/myuser/myproject.go'
buildah copy containerID '/home/myuser/myfiles.tar' '/tmp'
buildah copy containerID '/tmp/workingdir' '/tmp/workingdir'
buildah copy containerID 'https://github.com/containers/buildah' '/tmp'
buildah copy containerID 'passwd' 'certs.d' /etcFiles
.containerignore/.dockerignore
If the .containerignore/.dockerignore file exists in the context directory, buildahcopy reads its
contents. If both exist, then .containerignore is used.
When the --ignorefile option is specified Buildah reads it and uses it to decide which content to exclude
when copying content into the working container.
Users can specify a series of Unix shell glob patterns in an 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 .containerignore/.dockerignore file:
# here are files we want to exclude
*/*.c
**/output*
src
*/*.c Excludes files and directories whose names end 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 .containerignore/.dockerignore file that uses this mechanism:
*.doc
!Help.doc
Exclude all doc files except Help.doc when copying content into the container.
This functionality is compatible with the handling of .containerignore files described here:
https://github.com/containers/common/blob/main/docs/containerignore.5.md
Name
buildah-copy - Copies the contents of a file, URL, or directory into a container's working directory.
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. exportBUILDAH_HISTORY=true--cert-dirpath
Use certificates at path (*.crt, *.cert, *.key) when connecting to registries for pulling images named
with the --from flag. The default certificates directory is /etc/containers/certs.d.
--checksumchecksum
Checksum the source content. The value of checksum must be a standard container digest string. Only
supported for HTTP sources.
--chmodpermissions
Sets the access permissions of the destination content. Accepts the numerical format. If --from is not
used, defaults to 0755.
--chownowner:group
Sets the user and group ownership of the destination content. If --from is not used, defaults to 0:0.
--contextdirdirectory
Build context directory. Specifying a context directory causes Buildah to chroot into the context
directory. This means copying files pointed at by symbolic links outside of the chroot will fail.
--excludepattern
Exclude copying files matching the specified pattern. Option can be specified multiple times. See
containerignore(5) for supported formats.
--fromcontainerOrImage
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 buildahpull can be used. If --chown or --chmod are not used, permissions and ownership is
preserved.
--ignorefilefile
Path to an alternative .containerignore (.dockerignore) file. Requires --contextdir be specified.
--quiet, -q
Refrain from printing a digest of the copied content.
--retryattempts
Number of times to retry in case of failure when performing pull of images from registry.
Defaults to 3.
--retry-delayduration
Duration of delay between retry attempts in case of failure when performing pull of images from registry.
Defaults to 2s.
--tls-verifybool-value
Require verification of certificates when pulling images referred to with the --from* flag (defaults to
true). TLS verification cannot be used when talking to an insecure registry.
See Also
buildah(1), containerignore(5) buildah April 2021 buildah-copy(1)
Synopsis
buildahcopycontainersrc [[src ...] dest]
