2018-03-20 17:41:19 +08:00
# buildah-commit "1" "March 2017" "buildah"
2017-03-29 03:37:24 +08:00
## NAME
2018-04-26 21:01:15 +08:00
buildah\-commit - Create an image from a working container.
2017-03-29 03:37:24 +08:00
## SYNOPSIS
2019-11-19 04:40:43 +08:00
**buildah commit** [*options*] *container* [*image*]
2017-03-29 03:37:24 +08:00
## DESCRIPTION
2017-04-14 03:42:04 +08:00
Writes a new image using the specified container's read-write layer and if it
2018-06-30 03:39:36 +08:00
is based on an image, the layers of that image. If *image* does not begin
2019-11-19 04:40:43 +08:00
with a registry name component, `localhost` will be added to the name. If
2020-07-29 22:45:17 +08:00
*image* is not provided, the image will have no name. When an image has no
name, the `buildah images` command will display `<none>` in the `REPOSITORY` and
`TAG` columns.
2017-03-29 03:37:24 +08:00
2018-04-11 01:07:31 +08:00
## RETURN VALUE
The image ID of the image that was created. On error, 1 is returned and errno is returned.
2017-03-29 03:37:24 +08:00
## OPTIONS
2018-01-31 08:19:30 +08:00
**--authfile** *path*
2019-04-10 03:57:12 +08:00
Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `buildah login` .
2018-01-31 08:19:30 +08:00
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login` .
2017-08-25 05:44:32 +08:00
**--cert-dir** *path*
2018-05-02 03:37:13 +08:00
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
2020-09-09 16:25:25 +08:00
The default certificates directory is _/etc/containers/certs.d_ .
2017-08-25 05:44:32 +08:00
**--creds** *creds*
2018-01-25 06:49:37 +08:00
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.
2017-08-25 05:44:32 +08:00
2017-06-02 00:11:14 +08:00
**--disable-compression, -D**
2017-03-29 03:37:24 +08:00
2018-06-06 22:41:40 +08:00
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 ** --disable-compression=false**.
2017-04-14 03:42:04 +08:00
2017-05-18 05:02:40 +08:00
**--format**
Control the format for the image manifest and configuration data. Recognized
formats include *oci* (OCI image-spec v1.0, the default) and *docker* (version
2, using schema format 2 for the manifest).
2018-06-15 03:41:05 +08:00
Note: You can also override the default format by setting the BUILDAH\_FORMAT
2018-06-06 22:41:40 +08:00
environment variable. `export BUILDAH\_FORMAT=docker`
2018-06-01 22:26:34 +08:00
2018-04-25 22:00:46 +08:00
**--iidfile** *ImageIDfile*
Write the image ID to the file.
2017-09-22 17:37:40 +08:00
**--quiet**
When writing the output image, suppress progress output.
2017-07-14 20:57:26 +08:00
**--rm**
2020-07-29 22:45:17 +08:00
Remove the working container and its contents after creating the image.
2017-07-14 20:57:26 +08:00
Default leaves the container and its content in place.
2020-01-16 01:23:38 +08:00
**--sign-by** *fingerprint*
Sign the new image using the GPG key that matches the specified fingerprint.
2018-05-22 05:02:50 +08:00
**--squash**
Squash all of the new image's layers (including those inherited from a base image) into a single new layer.
2017-09-22 17:37:40 +08:00
**--tls-verify** *bool-value*
2020-09-09 16:25:25 +08:00
Require HTTPS and verify certificates when talking to container registries (defaults to true).
2017-09-22 17:37:40 +08:00
2020-08-27 04:56:57 +08:00
**--timestamp** *secconds*
2019-01-19 01:39:49 +08:00
2020-08-27 04:56:57 +08:00
Set the create timestamp to seconds since epoch to allow for deterministic builds (defaults to current time).
2019-01-19 01:39:49 +08:00
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.
2020-08-27 04:56:57 +08:00
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.
2019-01-19 01:39:49 +08:00
2017-03-29 03:37:24 +08:00
## EXAMPLE
2017-04-14 03:42:04 +08:00
2017-08-25 05:44:32 +08:00
This example saves an image based on the container.
2018-04-11 01:07:31 +08:00
`buildah commit containerID newImageName`
2017-08-25 05:44:32 +08:00
This example saves an image named newImageName based on the container.
`buildah commit --rm containerID newImageName`
2020-07-29 22:45:17 +08:00
This example saves an image with no name, removes the working container, and creates a new container using the image's ID.
`buildah from $(buildah commit --rm containerID)`
2017-08-25 05:44:32 +08:00
This example saves an image based on the container disabling compression.
`buildah commit --disable-compression containerID`
2017-04-14 03:42:04 +08:00
2017-08-25 05:44:32 +08:00
This example saves an image named newImageName based on the container disabling compression.
`buildah commit --disable-compression containerID newImageName`
2017-04-14 03:42:04 +08:00
2017-08-25 05:44:32 +08:00
This example commits the container to the image on the local registry while turning off tls verification.
`buildah commit --tls-verify=false containerID docker://localhost:5000/imageId`
2017-04-14 03:42:04 +08:00
2017-08-25 05:44:32 +08:00
This example commits the container to the image on the local registry using credentials and certificates for authentication.
`buildah commit --cert-dir ~/auth --tls-verify=true --creds=username:password containerID docker://localhost:5000/imageId`
2017-03-29 03:37:24 +08:00
2018-01-31 08:19:30 +08:00
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.
2018-05-02 03:37:13 +08:00
`buildah commit --authfile /tmp/auths/myauths.json --cert-dir ~/auth --tls-verify=true --creds=username:password containerID docker://localhost:5000/imageName`
2018-01-31 08:19:30 +08:00
2020-08-27 04:56:57 +08:00
This example saves an image based on the container, but stores dates based on epoch time.
`buildah commit --timestamp=0 containerID newImageName`
2019-08-13 12:23:28 +08:00
## ENVIRONMENT
**BUILD\_REGISTRY\_SOURCES**
BUILD\_REGISTRY\_SOURCES, if set, is treated as a JSON object which contains
lists of registry names under the keys `insecureRegistries` ,
`blockedRegistries` , and `allowedRegistries` .
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
`blockedRegistries` list, and if it matches any of them, the commit attempt is
denied. If there are registries in the `allowedRegistries` list, and the
portion of the name that corresponds to the registry is not in the list, the
commit attempt is denied.
2019-12-18 00:01:52 +08:00
**TMPDIR**
The TMPDIR environment variable allows the user to specify where temporary files
are stored while pulling and pushing images. Defaults to '/var/tmp'.
2019-08-13 12:23:28 +08:00
## FILES
2018-05-03 04:53:27 +08:00
**registries.conf** (`/etc/containers/registries.conf`)
2018-06-11 21:57:45 +08:00
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.
2018-05-03 04:53:27 +08:00
2019-02-27 23:29:09 +08:00
**policy.json** (`/etc/containers/policy.json`)
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.
2017-03-29 03:37:24 +08:00
## SEE ALSO
2020-07-29 22:45:17 +08:00
buildah(1), buildah-images(1), containers-policy.json(5), containers-registries.conf(5)