.nh .TH buildah-commit "1" "March 2017" "buildah" .SH NAME .PP buildah-commit - Create an image from a working container. .SH SYNOPSIS .PP \fBbuildah commit\fP [\fIoptions\fP] \fIcontainer\fP [\fIimage\fP] .SH DESCRIPTION .PP Writes a new image using the specified container's read-write layer and if it is based on an image, the layers of that image. If \fIimage\fP does not begin with a registry name component, \fBlocalhost\fR will be added to the name. If \fIimage\fP is not provided, the image will have no name. When an image has no name, the \fBbuildah images\fR command will display \fB\fR in the \fBREPOSITORY\fR and \fBTAG\fR columns. .SH RETURN VALUE .PP The image ID of the image that was created. On error, 1 is returned and errno is returned. .SH OPTIONS .PP \fB--authfile\fP \fIpath\fP .PP Path of the authentication file. Default is ${XDG_\\RUNTIME_DIR}/containers/auth.json. If XDG_RUNTIME_DIR is not set, the default is /run/containers/$UID/auth.json. This file is created using \fBbuildah login\fR\&. .PP If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using \fBdocker login\fR\&. .PP Note: You can also override the default path of the authentication file by setting the REGISTRY_AUTH_FILE environment variable. \fBexport REGISTRY_AUTH_FILE=path\fR .PP \fB--cert-dir\fP \fIpath\fP .PP Use certificates at \fIpath\fP (*\&.crt, *\&.cert, *\&.key) to connect to the registry. The default certificates directory is \fI/etc/containers/certs.d\fP\&. .PP \fB--change\fP, \fB-c\fP \fI"INSTRUCTION"\fP .PP Apply the change to the committed image that would have been made if it had been built using a Containerfile which included the specified instruction. This option can be specified multiple times. .PP \fB--config\fP \fIfilename\fP .PP Read a JSON-encoded version of an image configuration object from the specified file, and merge the values from it with the configuration of the image being committed. .PP \fB--creds\fP \fIcreds\fP .PP The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. .PP \fB--cw\fP \fIoptions\fP .PP Produce an image suitable for use as a confidential workload running in a trusted execution environment (TEE) using krun (i.e., \fIcrun\fP built with the libkrun feature enabled and invoked as \fIkrun\fP). Instead of the conventional contents, the root filesystem of the image will contain an encrypted disk image and configuration information for krun. .PP The value for \fIoptions\fP is a comma-separated list of key=value pairs, supplying configuration information which is needed for producing the additional data which will be included in the container image. .PP Recognized \fIkeys\fP are: .PP \fIattestation_url\fP: The location of a key broker / attestation server. If a value is specified, the new image's workload ID, along with the passphrase used to encrypt the disk image, will be registered with the server, and the server's location will be stored in the container image. At run-time, krun is expected to contact the server to retrieve the passphrase using the workload ID, which is also stored in the container image. If no value is specified, a \fIpassphrase\fP value \fImust\fP be specified. .PP \fIcpus\fP: The number of virtual CPUs which the image expects to be run with at run-time. If not specified, a default value will be supplied. .PP \fIfirmware_library\fP: The location of the libkrunfw-sev shared library. If not specified, \fBbuildah\fR checks for its presence in a number of hard-coded locations. .PP \fImemory\fP: The amount of memory which the image expects to be run with at run-time, as a number of megabytes. If not specified, a default value will be supplied. .PP \fIpassphrase\fP: The passphrase to use to encrypt the disk image which will be included in the container image. If no value is specified, but an \fIattestation_url\fP value is specified, a randomly-generated passphrase will be used. The authors recommend setting an \fIattestation_url\fP but not a \fIpassphrase\fP\&. .PP \fIslop\fP: Extra space to allocate for the disk image compared to the size of the container image's contents, expressed either as a percentage (..%) or a size value (bytes, or larger units if suffixes like KB or MB are present), or a sum of two or more such specifications separated by "+". If not specified, \fBbuildah\fR guesses that 25% more space than the contents will be enough, but this option is provided in case its guess is wrong. If the specified or computed size is less than 10 megabytes, it will be increased to 10 megabytes. .PP \fItype\fP: The type of trusted execution environment (TEE) which the image should be marked for use with. Accepted values are "SEV" (AMD Secure Encrypted Virtualization - Encrypted State) and "SNP" (AMD Secure Encrypted Virtualization - Secure Nested Paging). If not specified, defaults to "SNP". .PP \fIworkload_id\fP: A workload identifier which will be recorded in the container image, to be used at run-time for retrieving the passphrase which was used to encrypt the disk image. If not specified, a semi-random value will be derived from the base image's image ID. .PP \fB--disable-compression\fP, \fB-D\fP .PP Don't compress filesystem layers when building the image unless it is required by the location where the image is being written. This is the default setting, because image layers are compressed automatically when they are pushed to registries, and images being written to local storage would only need to be decompressed again to be stored. Compression can be forced in all cases by specifying \fB--disable-compression=false\fP\&. .PP \fB--encrypt-layer\fP \fIlayer(s)\fP .PP Layer(s) to encrypt: 0-indexed layer indices with support for negative indexing (e.g. 0 is the first layer, -1 is the last layer). If not defined, will encrypt all layers if encryption-key flag is specified. .PP \fB--encryption-key\fP \fIkey\fP .PP The [protocol:keyfile] specifies the encryption protocol, which can be JWE (RFC7516), PGP (RFC4880), and PKCS7 (RFC2315) and the key material required for image encryption. For instance, jwe:/path/to/key.pem or pgp:admin@example.com or pkcs7:/path/to/x509-file. .PP \fB--format\fP, \fB-f\fP \fI[oci | docker]\fP .PP Control the format for the image manifest and configuration data. Recognized formats include \fIoci\fP (OCI image-spec v1.0, the default) and \fIdocker\fP (version 2, using schema format 2 for the manifest). .PP Note: You can also override the default format by setting the BUILDAH_FORMAT environment variable. \fBexport BUILDAH\\_FORMAT=docker\fR .PP \fB--identity-label\fP \fIbool-value\fP .PP Adds default identity label \fBio.buildah.version\fR if set. (default true). .PP \fB--iidfile\fP \fIImageIDfile\fP .PP Write the image ID to the file. .PP \fB--manifest\fP "listName" .PP Name of the manifest list to which the built image will be added. Creates the manifest list if it does not exist. This option is useful for building multi architecture images. .PP \fB--omit-history\fP \fIbool-value\fP .PP Omit build history information in the built image. (default false). .PP This option is useful for the cases where end users explicitly want to set \fB--omit-history\fR to omit the optional \fBHistory\fR from built images or when working with images built using build tools that do not include \fBHistory\fR information in their images. .PP \fB--quiet\fP, \fB-q\fP .PP When writing the output image, suppress progress output. .PP \fB--rm\fP Remove the working container and its contents after creating the image. Default leaves the container and its content in place. .PP \fB--sign-by\fP \fIfingerprint\fP .PP Sign the new image using the GPG key that matches the specified fingerprint. .PP \fB--squash\fP .PP Squash all of the new image's layers (including those inherited from a base image) into a single new layer. .PP \fB--timestamp\fP \fIseconds\fP .PP Set the create timestamp to seconds since epoch to allow for deterministic builds (defaults to current time). By default, the created timestamp is changed and written into the image manifest with every commit, causing the image's sha256 hash to be different even if the sources are exactly the same otherwise. When --timestamp is set, the created timestamp is always set to the time specified and therefore not changed, allowing the image's sha256 to remain the same. All files committed to the layers of the image will be created with the timestamp. .PP \fB--tls-verify\fP \fIbool-value\fP .PP Require HTTPS and verification of certificates when talking to container registries (defaults to true). TLS verification cannot be used when talking to an insecure registry. .PP \fB--unsetenv\fP \fIenv\fP .PP Unset environment variables from the final image. .SH EXAMPLE .PP This example saves an image based on the container. \fBbuildah commit containerID newImageName\fR .PP This example saves an image named newImageName based on the container. \fBbuildah commit --rm containerID newImageName\fR .PP This example saves an image with no name, removes the working container, and creates a new container using the image's ID. \fBbuildah from $(buildah commit --rm containerID)\fR .PP This example saves an image based on the container disabling compression. \fBbuildah commit --disable-compression containerID\fR .PP This example saves an image named newImageName based on the container disabling compression. \fBbuildah commit --disable-compression containerID newImageName\fR .PP This example commits the container to the image on the local registry while turning off tls verification. \fBbuildah commit --tls-verify=false containerID docker://localhost:5000/imageId\fR .PP This example commits the container to the image on the local registry using credentials and certificates for authentication. \fBbuildah commit --cert-dir ~/auth --tls-verify=true --creds=username:password containerID docker://localhost:5000/imageId\fR .PP This example commits the container to the image on the local registry using credentials from the /tmp/auths/myauths.json file and certificates for authentication. \fBbuildah commit --authfile /tmp/auths/myauths.json --cert-dir ~/auth --tls-verify=true --creds=username:password containerID docker://localhost:5000/imageName\fR .PP This example saves an image based on the container, but stores dates based on epoch time. \fBbuildah commit --timestamp=0 containerID newImageName\fR .SS Building an multi-architecture image using the --manifest option (requires emulation software) .EX #!/bin/sh build() { ctr=$(./bin/buildah from --arch $1 ubi8) ./bin/buildah run $ctr dnf install -y iputils ./bin/buildah commit --manifest ubi8ping $ctr } build arm build amd64 build s390x .EE .SH ENVIRONMENT .PP \fBBUILD_REGISTRY_SOURCES\fP .PP BUILD_REGISTRY_SOURCES, if set, is treated as a JSON object which contains lists of registry names under the keys \fBinsecureRegistries\fR, \fBblockedRegistries\fR, and \fBallowedRegistries\fR\&. .PP When committing an image, if the image is to be given a name, the portion of the name that corresponds to a registry is compared to the items in the \fBblockedRegistries\fR list, and if it matches any of them, the commit attempt is denied. If there are registries in the \fBallowedRegistries\fR list, and the portion of the name that corresponds to the registry is not in the list, the commit attempt is denied. .PP \fBTMPDIR\fP The TMPDIR environment variable allows the user to specify where temporary files are stored while pulling and pushing images. Defaults to '/var/tmp'. .SH FILES .PP \fBregistries.conf\fP (\fB/etc/containers/registries.conf\fR) .PP registries.conf is the configuration file which specifies which container registries should be consulted when completing image names which do not include a registry or domain portion. .PP \fBpolicy.json\fP (\fB/etc/containers/policy.json\fR) .PP Signature policy file. This defines the trust policy for container images. Controls which container registries can be used for image, and whether or not the tool should trust the images. .SH SEE ALSO .PP buildah(1), buildah-images(1), containers-policy.json(5), containers-registries.conf(5)