...
This commit is contained in:
232
packages/system/virt/src/buildah/README.md
Normal file
232
packages/system/virt/src/buildah/README.md
Normal file
@@ -0,0 +1,232 @@
|
||||
# SAL Buildah Module (`sal::virt::buildah`)
|
||||
|
||||
## Overview
|
||||
|
||||
The Buildah module in SAL provides a comprehensive Rust interface for interacting with the `buildah` command-line tool. It allows users to build OCI (Open Container Initiative) and Docker-compatible container images programmatically. The module offers both a high-level `Builder` API for step-by-step image construction and static functions for managing images in local storage.
|
||||
|
||||
A Rhai script interface for this module is also available via `sal::rhai::buildah`, making these functionalities accessible from `herodo` scripts.
|
||||
|
||||
## Core Components
|
||||
|
||||
### 1. `Builder` Struct (`sal::virt::buildah::Builder`)
|
||||
|
||||
The `Builder` struct is the primary entry point for constructing container images. It encapsulates a Buildah working container, created from a base image, and provides methods to modify this container and eventually commit it as a new image.
|
||||
|
||||
- **Creation**: `Builder::new(name: &str, image: &str) -> Result<Builder, BuildahError>`
|
||||
- Creates a new working container (or re-attaches to an existing one with the same name) from the specified base `image`.
|
||||
- **Debug Mode**: `builder.set_debug(true)` / `builder.debug()`
|
||||
- Enables/disables verbose logging for Buildah commands executed by this builder instance.
|
||||
|
||||
#### Working Container Operations:
|
||||
|
||||
- `builder.run(command: &str) -> Result<CommandResult, BuildahError>`: Executes a shell command inside the working container (e.g., `buildah run <container> -- <command>`).
|
||||
- `builder.run_with_isolation(command: &str, isolation: &str) -> Result<CommandResult, BuildahError>`: Runs a command with specified isolation (e.g., "chroot").
|
||||
- `builder.copy(source_on_host: &str, dest_in_container: &str) -> Result<CommandResult, BuildahError>`: Copies files/directories from the host to the container (`buildah copy`).
|
||||
- `builder.add(source_on_host: &str, dest_in_container: &str) -> Result<CommandResult, BuildahError>`: Adds files/directories to the container (`buildah add`), potentially handling URLs and archive extraction.
|
||||
- `builder.config(options: HashMap<String, String>) -> Result<CommandResult, BuildahError>`: Modifies image metadata (e.g., environment variables, labels, entrypoint, cmd). Example options: `{"env": "MYVAR=value", "label": "mylabel=myvalue"}`.
|
||||
- `builder.set_entrypoint(entrypoint: &str) -> Result<CommandResult, BuildahError>`: Sets the image entrypoint.
|
||||
- `builder.set_cmd(cmd: &str) -> Result<CommandResult, BuildahError>`: Sets the default command for the image.
|
||||
- `builder.commit(image_name: &str) -> Result<CommandResult, BuildahError>`: Commits the current state of the working container to a new image named `image_name`.
|
||||
- `builder.remove() -> Result<CommandResult, BuildahError>`: Removes the working container (`buildah rm`).
|
||||
- `builder.reset() -> Result<(), BuildahError>`: Removes the working container and resets the builder state.
|
||||
|
||||
### 2. Static Image Management Functions (on `Builder`)
|
||||
|
||||
These functions operate on images in the local Buildah storage and are not tied to a specific `Builder` instance.
|
||||
|
||||
- `Builder::images() -> Result<Vec<Image>, BuildahError>`: Lists all images available locally (`buildah images --json`). Returns a vector of `Image` structs.
|
||||
- `Builder::image_remove(image_ref: &str) -> Result<CommandResult, BuildahError>`: Removes an image (`buildah rmi <image_ref>`).
|
||||
- `Builder::image_pull(image_name: &str, tls_verify: bool) -> Result<CommandResult, BuildahError>`: Pulls an image from a registry (`buildah pull`).
|
||||
- `Builder::image_push(image_ref: &str, destination: &str, tls_verify: bool) -> Result<CommandResult, BuildahError>`: Pushes an image to a registry (`buildah push`).
|
||||
- `Builder::image_tag(image_ref: &str, new_name: &str) -> Result<CommandResult, BuildahError>`: Tags an image (`buildah tag`).
|
||||
- `Builder::image_commit(container_ref: &str, image_name: &str, format: Option<&str>, squash: bool, rm: bool) -> Result<CommandResult, BuildahError>`: A static version to commit any existing container to an image, with options for format (e.g., "oci", "docker"), squashing layers, and removing the container post-commit.
|
||||
- `Builder::build(tag: Option<&str>, context_dir: &str, file: &str, isolation: Option<&str>) -> Result<CommandResult, BuildahError>`: Builds an image from a Dockerfile/Containerfile (`buildah bud`).
|
||||
|
||||
*Note: Many static image functions also have a `_with_debug(..., debug: bool)` variant for explicit debug control.*
|
||||
|
||||
### 3. `Image` Struct (`sal::virt::buildah::Image`)
|
||||
|
||||
Represents a container image as listed by `buildah images`.
|
||||
|
||||
```rust
|
||||
pub struct Image {
|
||||
pub id: String, // Image ID
|
||||
pub names: Vec<String>, // Image names/tags
|
||||
pub size: String, // Image size
|
||||
pub created: String, // Creation timestamp (as string)
|
||||
}
|
||||
```
|
||||
|
||||
### 4. `ContentOperations` (`sal::virt::buildah::ContentOperations`)
|
||||
|
||||
Provides static methods for reading and writing file content directly within a container, useful for dynamic configuration or inspection.
|
||||
|
||||
- `ContentOperations::write_content(container_id: &str, content: &str, dest_path_in_container: &str) -> Result<CommandResult, BuildahError>`: Writes string content to a file inside the specified container.
|
||||
- `ContentOperations::read_content(container_id: &str, source_path_in_container: &str) -> Result<String, BuildahError>`: Reads the content of a file from within the specified container into a string.
|
||||
|
||||
### 5. `BuildahError` Enum (`sal::virt::buildah::BuildahError`)
|
||||
|
||||
Defines the error types that can occur during Buildah operations:
|
||||
- `CommandExecutionFailed(io::Error)`: The `buildah` command itself failed to start.
|
||||
- `CommandFailed(String)`: The `buildah` command ran but returned a non-zero exit code or error.
|
||||
- `JsonParseError(String)`: Failed to parse JSON output from Buildah.
|
||||
- `ConversionError(String)`: Error during data conversion.
|
||||
- `Other(String)`: Generic error.
|
||||
|
||||
## Key Design Points
|
||||
|
||||
The SAL Buildah module is designed with the following principles:
|
||||
|
||||
- **Builder Pattern**: The `Builder` struct (`sal::virt::buildah::Builder`) employs a builder pattern, enabling a fluent, step-by-step, and stateful approach to constructing container images. Each `Builder` instance manages a specific working container.
|
||||
- **Separation of Concerns**:
|
||||
- **Instance Methods**: Operations specific to a working container (e.g., `run`, `copy`, `config`, `commit`) are methods on the `Builder` instance.
|
||||
- **Static Methods**: General image management tasks (e.g., listing images with `Builder::images()`, removing images with `Builder::image_remove()`, pulling, pushing, tagging, and building from a Dockerfile with `Builder::build()`) are provided as static functions on the `Builder` struct.
|
||||
- **Direct Content Manipulation**: The `ContentOperations` struct provides static methods (`write_content`, `read_content`) to directly interact with files within a Buildah container. This is typically achieved by temporarily mounting the container or using `buildah add` with temporary files, abstracting the complexity from the user.
|
||||
- **Debuggability**: Fine-grained control over `buildah` command logging is provided. The `builder.set_debug(true)` method enables verbose output for a specific `Builder` instance. Many static functions also offer `_with_debug(..., debug: bool)` variants. This is managed internally via a thread-local flag passed to the core `execute_buildah_command` function.
|
||||
- **Comprehensive Rhai Integration**: Most functionalities of the Buildah module are exposed to Rhai scripts executed via `herodo`, allowing for powerful automation of image building workflows. This is facilitated by the `sal::rhai::buildah` module.
|
||||
|
||||
## Low-Level Command Execution
|
||||
|
||||
- `execute_buildah_command(args: &[&str]) -> Result<CommandResult, BuildahError>` (in `sal::virt::buildah::cmd`):
|
||||
The core function that executes `buildah` commands. It handles debug logging based on a thread-local flag, which is managed by the higher-level `Builder` methods and `_with_debug` static function variants.
|
||||
|
||||
## Usage Example (Rust)
|
||||
|
||||
```rust
|
||||
use sal::virt::buildah::{Builder, BuildahError, ContentOperations};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn build_custom_image() -> Result<String, BuildahError> {
|
||||
// Create a new builder from a base image (e.g., alpine)
|
||||
let mut builder = Builder::new("my-custom-container", "docker.io/library/alpine:latest")?;
|
||||
builder.set_debug(true);
|
||||
|
||||
// Run some commands
|
||||
builder.run("apk add --no-cache curl")?;
|
||||
builder.run("mkdir /app")?;
|
||||
|
||||
// Add a file
|
||||
ContentOperations::write_content(builder.container_id().unwrap(), "Hello from SAL!", "/app/hello.txt")?;
|
||||
|
||||
// Set image configuration
|
||||
let mut config_opts = HashMap::new();
|
||||
config_opts.insert("workingdir".to_string(), "/app".to_string());
|
||||
config_opts.insert("label".to_string(), "maintainer=sal-user".to_string());
|
||||
builder.config(config_opts)?;
|
||||
builder.set_entrypoint("["/usr/bin/curl"]")?;
|
||||
builder.set_cmd("["http://ifconfig.me"]")?;
|
||||
|
||||
// Commit the image
|
||||
let image_tag = "localhost/my-custom-image:latest";
|
||||
builder.commit(image_tag)?;
|
||||
|
||||
println!("Successfully built image: {}", image_tag);
|
||||
|
||||
// Clean up the working container
|
||||
builder.remove()?;
|
||||
|
||||
Ok(image_tag.to_string())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match build_custom_image() {
|
||||
Ok(tag) => println!("Image {} created.", tag),
|
||||
Err(e) => eprintln!("Error building image: {}", e),
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Rhai Scripting with `herodo`
|
||||
|
||||
The Buildah module's capabilities are extensively exposed to Rhai scripts, enabling automation of image building and management tasks via the `herodo` CLI tool. The `sal::rhai::buildah` module registers the necessary functions and types.
|
||||
|
||||
Below is a summary of commonly used Rhai functions for Buildah. (Note: `builder` refers to an instance of `BuildahBuilder` obtained typically via `bah_new`).
|
||||
|
||||
### Builder Object Management
|
||||
- `bah_new(name: String, image: String) -> BuildahBuilder`: Creates a new Buildah builder instance (working container) from a base `image` with a given `name`.
|
||||
- `builder.remove()`: Removes the working container associated with the `builder`.
|
||||
- `builder.reset()`: Removes the working container and resets the `builder` state.
|
||||
|
||||
### Builder Configuration & Operations
|
||||
- `builder.set_debug(is_debug: bool)`: Enables or disables verbose debug logging for commands executed by this `builder`.
|
||||
- `builder.debug_mode` (property): Get or set the debug mode (e.g., `let mode = builder.debug_mode; builder.debug_mode = true;`).
|
||||
- `builder.container_id` (property): Returns the ID of the working container (e.g., `let id = builder.container_id;`).
|
||||
- `builder.name` (property): Returns the name of the builder/working container.
|
||||
- `builder.image` (property): Returns the base image name used by the builder.
|
||||
- `builder.run(command: String)`: Executes a shell command inside the `builder`'s working container.
|
||||
- `builder.run_with_isolation(command: String, isolation: String)`: Runs a command with specified isolation (e.g., "chroot").
|
||||
- `builder.copy(source_on_host: String, dest_in_container: String)`: Copies files/directories from the host to the `builder`'s container.
|
||||
- `builder.add(source_on_host: String, dest_in_container: String)`: Adds files/directories to the `builder`'s container (can handle URLs and auto-extract archives).
|
||||
- `builder.config(options: Map)`: Modifies image metadata. `options` is a Rhai map, e.g., `#{ "env": "MYVAR=value", "label": "foo=bar" }`.
|
||||
- `builder.set_entrypoint(entrypoint: String)`: Sets the image entrypoint (e.g., `builder.set_entrypoint("[/app/run.sh]")`).
|
||||
- `builder.set_cmd(cmd: String)`: Sets the default command for the image (e.g., `builder.set_cmd("[--help]")`).
|
||||
- `builder.commit(image_tag: String)`: Commits the current state of the `builder`'s working container to a new image with `image_tag`.
|
||||
|
||||
### Content Operations (with a Builder instance)
|
||||
- `bah_write_content(builder: BuildahBuilder, content: String, dest_path_in_container: String)`: Writes string `content` to a file at `dest_path_in_container` inside the `builder`'s container.
|
||||
- `bah_read_content(builder: BuildahBuilder, source_path_in_container: String) -> String`: Reads the content of a file from `source_path_in_container` within the `builder`'s container.
|
||||
|
||||
### Global Image Operations
|
||||
These functions generally correspond to static methods in Rust and operate on the local Buildah image storage.
|
||||
- `bah_images() -> Array`: Lists all images available locally. Returns an array of `BuildahImage` objects.
|
||||
- `bah_image_remove(image_ref: String)`: Removes an image (e.g., by ID or tag) from local storage.
|
||||
- `bah_image_pull(image_name: String, tls_verify: bool)`: Pulls an image from a registry.
|
||||
- `bah_image_push(image_ref: String, destination: String, tls_verify: bool)`: Pushes a local image to a registry.
|
||||
- `bah_image_tag(image_ref: String, new_name: String)`: Adds a new tag (`new_name`) to an existing image (`image_ref`).
|
||||
- `bah_build(tag: String, context_dir: String, file: String, isolation: String)`: Builds an image from a Dockerfile/Containerfile (equivalent to `buildah bud`). `file` is the path to the Dockerfile relative to `context_dir`. `isolation` can be e.g., "chroot".
|
||||
|
||||
### Example `herodo` Rhai Script (Revisited)
|
||||
|
||||
```rhai
|
||||
// Create a new builder
|
||||
let builder = bah_new("my-rhai-app", "docker.io/library/alpine:latest");
|
||||
builder.debug_mode = true; // Enable debug logging for this builder
|
||||
|
||||
// Run commands in the container
|
||||
builder.run("apk add --no-cache figlet curl");
|
||||
builder.run("mkdir /data");
|
||||
|
||||
// Write content to a file in the container
|
||||
bah_write_content(builder, "Hello from SAL Buildah via Rhai!", "/data/message.txt");
|
||||
|
||||
// Configure image metadata
|
||||
builder.config(#{
|
||||
"env": "APP_VERSION=1.0",
|
||||
"label": "author=HerodoUser"
|
||||
});
|
||||
builder.set_entrypoint('["figlet"]');
|
||||
builder.set_cmd('["Rhai Build"]');
|
||||
|
||||
// Commit the image
|
||||
let image_name = "localhost/my-rhai-app:v1";
|
||||
builder.commit(image_name);
|
||||
print(`Image committed: ${image_name}`);
|
||||
|
||||
// Clean up the working container
|
||||
builder.remove();
|
||||
print("Builder container removed.");
|
||||
|
||||
// List local images
|
||||
print("Current local images:");
|
||||
let images = bah_images();
|
||||
for img in images {
|
||||
print(` ID: ${img.id}, Name(s): ${img.names}, Size: ${img.size}`);
|
||||
}
|
||||
|
||||
// Example: Build from a Dockerfile (assuming Dockerfile exists at /tmp/build_context/Dockerfile)
|
||||
// Ensure /tmp/build_context/Dockerfile exists with simple content like:
|
||||
// FROM alpine
|
||||
// RUN echo "Built with bah_build" > /built.txt
|
||||
// CMD cat /built.txt
|
||||
//
|
||||
// if exist("/tmp/build_context/Dockerfile") {
|
||||
// print("Building from Dockerfile...");
|
||||
// bah_build("localhost/from-dockerfile:latest", "/tmp/build_context", "Dockerfile", "chroot");
|
||||
// print("Dockerfile build complete.");
|
||||
// bah_image_remove("localhost/from-dockerfile:latest"); // Clean up
|
||||
// } else {
|
||||
// print("Skipping Dockerfile build example: /tmp/build_context/Dockerfile not found.");
|
||||
// }
|
||||
```
|
||||
|
||||
This README provides a guide to using the SAL Buildah module. For more detailed information on specific functions and their parameters, consult the Rust doc comments within the source code.
|
33
packages/system/virt/src/buildah/buildahdocs/Makefile
Normal file
33
packages/system/virt/src/buildah/buildahdocs/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
PREFIX := /usr/local
|
||||
DATADIR := ${PREFIX}/share
|
||||
MANDIR := $(DATADIR)/man
|
||||
# Following go-md2man is guaranteed on host
|
||||
GOMD2MAN ?= ../tests/tools/build/go-md2man
|
||||
ifeq ($(shell uname -s),FreeBSD)
|
||||
SED=gsed
|
||||
else
|
||||
SED=sed
|
||||
endif
|
||||
|
||||
docs: $(patsubst %.md,%,$(wildcard *.md))
|
||||
|
||||
%.1: %.1.md
|
||||
### sed is used to filter http/s links as well as relative links
|
||||
### replaces "\" at the end of a line with two spaces
|
||||
### this ensures that manpages are rendered correctly
|
||||
@$(SED) -e 's/\((buildah[^)]*\.md\(#.*\)\?)\)//g' \
|
||||
-e 's/\[\(buildah[^]]*\)\]/\1/g' \
|
||||
-e 's/\[\([^]]*\)](http[^)]\+)/\1/g' \
|
||||
-e 's;<\(/\)\?\(a\|a\s\+[^>]*\|sup\)>;;g' \
|
||||
-e 's/\\$$/ /g' $< | \
|
||||
$(GOMD2MAN) -in /dev/stdin -out $@
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
install -d ${DESTDIR}/${MANDIR}/man1
|
||||
install -m 0644 buildah*.1 ${DESTDIR}/${MANDIR}/man1
|
||||
install -m 0644 links/buildah*.1 ${DESTDIR}/${MANDIR}/man1
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) buildah*.1
|
162
packages/system/virt/src/buildah/buildahdocs/buildah-add.1.md
Normal file
162
packages/system/virt/src/buildah/buildahdocs/buildah-add.1.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# buildah-add "1" "April 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-add - Add the contents of a file, URL, or a directory to a container.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah add** [*options*] *container* *src* [[*src* ...] *dest*]
|
||||
|
||||
## DESCRIPTION
|
||||
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.
|
||||
|
||||
## 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. `export BUILDAH_HISTORY=true`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) when connecting to
|
||||
registries for pulling images named with the **--from** flag, and when
|
||||
connecting to HTTPS servers when fetching sources from locations specified with
|
||||
HTTPS URLs. The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--checksum** *checksum*
|
||||
|
||||
Checksum the source content. The value of *checksum* must be a standard
|
||||
container digest string. Only supported for HTTP sources.
|
||||
|
||||
**--chmod** *permissions*
|
||||
|
||||
Sets the access permissions of the destination content. Accepts the numerical format.
|
||||
|
||||
**--chown** *owner*:*group*
|
||||
|
||||
Sets the user and group ownership of the destination content.
|
||||
|
||||
**--contextdir** *directory*
|
||||
|
||||
Build context directory. Specifying a context directory causes Buildah to
|
||||
chroot into that context directory. This means copying files pointed at
|
||||
by symbolic links outside of the chroot will fail.
|
||||
|
||||
**--exclude** *pattern*
|
||||
|
||||
Exclude copying files matching the specified pattern. Option can be specified
|
||||
multiple times. See containerignore(5) for supported formats.
|
||||
|
||||
**--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.
|
||||
|
||||
**--ignorefile** *file*
|
||||
|
||||
Path to an alternative .containerignore (.dockerignore) file. Requires \-\-contextdir be specified.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Refrain from printing a digest of the added content.
|
||||
|
||||
**--retry** *attempts*
|
||||
|
||||
Number of times to retry in case of failure when pulling images from registries
|
||||
or retrieving content from HTTPS URLs.
|
||||
|
||||
Defaults to `3`.
|
||||
|
||||
**--retry-delay** *duration*
|
||||
|
||||
Duration of delay between retry attempts in case of failure when pulling images
|
||||
from registries or retrieving content from HTTPS URLs.
|
||||
|
||||
Defaults to `2s`.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
Require verification of certificates when retrieving sources from HTTPS
|
||||
locations, or when pulling images referred to with the **--from*** flag
|
||||
(defaults to true). TLS verification cannot be used when talking to an
|
||||
insecure registry.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah add containerID '/myapp/app.conf' '/myapp/app.conf'
|
||||
|
||||
buildah add --chown myuser:mygroup containerID '/myapp/app.conf' '/myapp/app.conf'
|
||||
|
||||
buildah add --chmod 660 containerID '/myapp/app.conf' '/myapp/app.conf'
|
||||
|
||||
buildah add containerID '/home/myuser/myproject.go'
|
||||
|
||||
buildah add containerID '/home/myuser/myfiles.tar' '/tmp'
|
||||
|
||||
buildah add containerID '/tmp/workingdir' '/tmp/workingdir'
|
||||
|
||||
buildah add containerID 'https://github.com/containers/buildah/blob/main/README.md' '/tmp'
|
||||
|
||||
buildah add containerID 'passwd' 'certs.d' /etc
|
||||
|
||||
## FILES
|
||||
|
||||
### .containerignore or .dockerignore
|
||||
|
||||
If a .containerignore or .dockerignore file exists in the context directory,
|
||||
`buildah add` 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 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
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), containerignore(5)
|
1448
packages/system/virt/src/buildah/buildahdocs/buildah-build.1.md
Normal file
1448
packages/system/virt/src/buildah/buildahdocs/buildah-build.1.md
Normal file
File diff suppressed because it is too large
Load Diff
393
packages/system/virt/src/buildah/buildahdocs/buildah-commit.1.md
Normal file
393
packages/system/virt/src/buildah/buildahdocs/buildah-commit.1.md
Normal file
@@ -0,0 +1,393 @@
|
||||
# buildah-commit "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-commit - Create an image from a working container.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah commit** [*options*] *container* [*image*]
|
||||
|
||||
## DESCRIPTION
|
||||
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 *image* does not begin
|
||||
with a registry name component, `localhost` will be added to the name. If
|
||||
*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.
|
||||
|
||||
The *image* value supports all transports from `containers-transports(5)`. If no transport is specified, the `containers-storage` (i.e., local storage) transport is used.
|
||||
|
||||
## RETURN VALUE
|
||||
The image ID of the image that was created. On error, 1 is returned and errno is returned.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--add-file** *source[:destination]*
|
||||
|
||||
Read the contents of the file `source` and add it to the committed image as a
|
||||
file at `destination`. If `destination` is not specified, the path of `source`
|
||||
will be used. The new file will be owned by UID 0, GID 0, have 0644
|
||||
permissions, and be given a current timestamp unless the **--timestamp** option
|
||||
is also specified. This option can be specified multiple times.
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login`.
|
||||
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--change**, **-c** *"INSTRUCTION"*
|
||||
|
||||
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.
|
||||
|
||||
**--config** *filename*
|
||||
|
||||
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.
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--cw** *options*
|
||||
|
||||
Produce an image suitable for use as a confidential workload running in a
|
||||
trusted execution environment (TEE) using krun (i.e., *crun* built with the
|
||||
libkrun feature enabled and invoked as *krun*). Instead of the conventional
|
||||
contents, the root filesystem of the image will contain an encrypted disk image
|
||||
and configuration information for krun.
|
||||
|
||||
The value for *options* 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.
|
||||
|
||||
Recognized _keys_ are:
|
||||
|
||||
*attestation_url*: 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 *passphrase* value *must* be specified.
|
||||
|
||||
*cpus*: 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.
|
||||
|
||||
*firmware_library*: The location of the libkrunfw-sev shared library. If not
|
||||
specified, `buildah` checks for its presence in a number of hard-coded
|
||||
locations.
|
||||
|
||||
*memory*: 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.
|
||||
|
||||
*passphrase*: The passphrase to use to encrypt the disk image which will be
|
||||
included in the container image.
|
||||
If no value is specified, but an *attestation_url* value is specified, a
|
||||
randomly-generated passphrase will be used.
|
||||
The authors recommend setting an *attestation_url* but not a *passphrase*.
|
||||
|
||||
*slop*: 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,
|
||||
`buildah` 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.
|
||||
|
||||
*type*: 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".
|
||||
|
||||
*workload_id*: 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.
|
||||
|
||||
**--disable-compression**, **-D**
|
||||
|
||||
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**.
|
||||
|
||||
**--encrypt-layer** *layer(s)*
|
||||
|
||||
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.
|
||||
|
||||
**--encryption-key** *key*
|
||||
|
||||
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.
|
||||
|
||||
**--format**, **-f** *[oci | docker]*
|
||||
|
||||
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).
|
||||
|
||||
Note: You can also override the default format by setting the BUILDAH_FORMAT
|
||||
environment variable. `export BUILDAH_FORMAT=docker`
|
||||
|
||||
**--identity-label** *bool-value*
|
||||
|
||||
Adds default identity label `io.buildah.version` if set. (default true).
|
||||
|
||||
**--iidfile** *ImageIDfile*
|
||||
|
||||
Write the image ID to the file.
|
||||
|
||||
**--manifest** "listName"
|
||||
|
||||
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.
|
||||
|
||||
**--omit-history** *bool-value*
|
||||
|
||||
Omit build history information in the built image. (default false).
|
||||
|
||||
This option is useful for the cases where end users explicitly
|
||||
want to set `--omit-history` to omit the optional `History` from
|
||||
built images or when working with images built using build tools that
|
||||
do not include `History` information in their images.
|
||||
|
||||
**--pull**
|
||||
|
||||
When the *--pull* flag is enabled or set explicitly to `true` (with
|
||||
*--pull=true*), attempt to pull the latest versions of SBOM scanner images from
|
||||
the registries listed in registries.conf if a local SBOM scanner image does not
|
||||
exist or the image in the registry is newer than the one in local storage.
|
||||
Raise an error if the SBOM scanner image is not in any listed registry and is
|
||||
not present locally.
|
||||
|
||||
If the flag is disabled (with *--pull=false*), do not pull SBOM scanner images
|
||||
from registries, use only local versions. Raise an error if a SBOM scanner
|
||||
image is not present locally.
|
||||
|
||||
If the pull flag is set to `always` (with *--pull=always*), pull SBOM scanner
|
||||
images from the registries listed in registries.conf. Raise an error if a SBOM
|
||||
scanner image is not found in the registries, even if an image with the same
|
||||
name is present locally.
|
||||
|
||||
If the pull flag is set to `missing` (with *--pull=missing*), pull SBOM scanner
|
||||
images only if they could not be found in the local containers storage. Raise
|
||||
an error if no image could be found and the pull fails.
|
||||
|
||||
If the pull flag is set to `never` (with *--pull=never*), do not pull SBOM
|
||||
scanner images from registries, use only the local versions. Raise an error if
|
||||
the image is not present locally.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
When writing the output image, suppress progress output.
|
||||
|
||||
**--rm**
|
||||
Remove the working container and its contents after creating the image.
|
||||
Default leaves the container and its content in place.
|
||||
|
||||
**--sbom** *preset*
|
||||
|
||||
Generate SBOMs (Software Bills Of Materials) for the output image by scanning
|
||||
the working container and build contexts using the named combination of scanner
|
||||
image, scanner commands, and merge strategy. Must be specified with one or
|
||||
more of **--sbom-image-output**, **--sbom-image-purl-output**, **--sbom-output**,
|
||||
and **--sbom-purl-output**. Recognized presets, and the set of options which
|
||||
they equate to:
|
||||
|
||||
- "syft", "syft-cyclonedx":
|
||||
--sbom-scanner-image=ghcr.io/anchore/syft
|
||||
--sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output cyclonedx-json={OUTPUT}"
|
||||
--sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output cyclonedx-json={OUTPUT}"
|
||||
--sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
|
||||
- "syft-spdx":
|
||||
--sbom-scanner-image=ghcr.io/anchore/syft
|
||||
--sbom-scanner-command="/syft scan -q dir:{ROOTFS} --output spdx-json={OUTPUT}"
|
||||
--sbom-scanner-command="/syft scan -q dir:{CONTEXT} --output spdx-json={OUTPUT}"
|
||||
--sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
|
||||
- "trivy", "trivy-cyclonedx":
|
||||
--sbom-scanner-image=ghcr.io/aquasecurity/trivy
|
||||
--sbom-scanner-command="trivy filesystem -q {ROOTFS} --format cyclonedx --output {OUTPUT}"
|
||||
--sbom-scanner-command="trivy filesystem -q {CONTEXT} --format cyclonedx --output {OUTPUT}"
|
||||
--sbom-merge-strategy=merge-cyclonedx-by-component-name-and-version
|
||||
- "trivy-spdx":
|
||||
--sbom-scanner-image=ghcr.io/aquasecurity/trivy
|
||||
--sbom-scanner-command="trivy filesystem -q {ROOTFS} --format spdx-json --output {OUTPUT}"
|
||||
--sbom-scanner-command="trivy filesystem -q {CONTEXT} --format spdx-json --output {OUTPUT}"
|
||||
--sbom-merge-strategy=merge-spdx-by-package-name-and-versioninfo
|
||||
|
||||
**--sbom-image-output** *path*
|
||||
|
||||
When generating SBOMs, store the generated SBOM in the specified path in the
|
||||
output image. There is no default.
|
||||
|
||||
**--sbom-image-purl-output** *path*
|
||||
|
||||
When generating SBOMs, scan them for PURL ([package
|
||||
URL](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst))
|
||||
information, and save a list of found PURLs to the named file in the local
|
||||
filesystem. There is no default.
|
||||
|
||||
**--sbom-merge-strategy** *method*
|
||||
|
||||
If more than one **--sbom-scanner-command** value is being used, use the
|
||||
specified method to merge the output from later commands with output from
|
||||
earlier commands. Recognized values include:
|
||||
|
||||
- cat
|
||||
Concatenate the files.
|
||||
- merge-cyclonedx-by-component-name-and-version
|
||||
Merge the "component" fields of JSON documents, ignoring values from
|
||||
documents when the combination of their "name" and "version" values is
|
||||
already present. Documents are processed in the order in which they are
|
||||
generated, which is the order in which the commands that generate them
|
||||
were specified.
|
||||
- merge-spdx-by-package-name-and-versioninfo
|
||||
Merge the "package" fields of JSON documents, ignoring values from
|
||||
documents when the combination of their "name" and "versionInfo" values is
|
||||
already present. Documents are processed in the order in which they are
|
||||
generated, which is the order in which the commands that generate them
|
||||
were specified.
|
||||
|
||||
**--sbom-output** *file*
|
||||
|
||||
When generating SBOMs, store the generated SBOM in the named file on the local
|
||||
filesystem. There is no default.
|
||||
|
||||
**--sbom-purl-output** *file*
|
||||
|
||||
When generating SBOMs, scan them for PURL ([package
|
||||
URL](https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst))
|
||||
information, and save a list of found PURLs to the named file in the local
|
||||
filesystem. There is no default.
|
||||
|
||||
**--sbom-scanner-command** *image*
|
||||
|
||||
Generate SBOMs by running the specified command from the scanner image. If
|
||||
multiple commands are specified, they are run in the order in which they are
|
||||
specified. These text substitutions are performed:
|
||||
- {ROOTFS}
|
||||
The root of the built image's filesystem, bind mounted.
|
||||
- {CONTEXT}
|
||||
The build context and additional build contexts, bind mounted.
|
||||
- {OUTPUT}
|
||||
The name of a temporary output file, to be read and merged with others or copied elsewhere.
|
||||
|
||||
**--sbom-scanner-image** *image*
|
||||
|
||||
Generate SBOMs using the specified scanner image.
|
||||
|
||||
**--sign-by** *fingerprint*
|
||||
|
||||
Sign the new image using the GPG key that matches the specified fingerprint.
|
||||
|
||||
**--squash**
|
||||
|
||||
Squash all of the new image's layers (including those inherited from a base image) into a single new layer.
|
||||
|
||||
**--timestamp** *seconds*
|
||||
|
||||
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.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
**--unsetenv** *env*
|
||||
|
||||
Unset environment variables from the final image.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
This example saves an image based on the container.
|
||||
`buildah commit containerID newImageName`
|
||||
|
||||
This example saves an image named newImageName based on the container and removes the working container.
|
||||
`buildah commit --rm containerID newImageName`
|
||||
|
||||
This example commits to an OCI archive file named /tmp/newImageName based on the container.
|
||||
`buildah commit containerID oci-archive:/tmp/newImageName`
|
||||
|
||||
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)`
|
||||
|
||||
This example saves an image based on the container disabling compression.
|
||||
`buildah commit --disable-compression containerID`
|
||||
|
||||
This example saves an image named newImageName based on the container disabling compression.
|
||||
`buildah commit --disable-compression containerID newImageName`
|
||||
|
||||
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`
|
||||
|
||||
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`
|
||||
|
||||
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.
|
||||
`buildah commit --authfile /tmp/auths/myauths.json --cert-dir ~/auth --tls-verify=true --creds=username:password containerID docker://localhost:5000/imageName`
|
||||
|
||||
This example saves an image based on the container, but stores dates based on epoch time.
|
||||
`buildah commit --timestamp=0 containerID newImageName`
|
||||
|
||||
### Building an multi-architecture image using the --manifest option (requires emulation software)
|
||||
|
||||
```
|
||||
#!/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
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
**TMPDIR**
|
||||
The TMPDIR environment variable allows the user to specify where temporary files
|
||||
are stored while pulling and pushing images. Defaults to '/var/tmp'.
|
||||
|
||||
## FILES
|
||||
|
||||
**registries.conf** (`/etc/containers/registries.conf`)
|
||||
|
||||
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.
|
||||
|
||||
**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.
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-images(1), containers-policy.json(5), containers-registries.conf(5), containers-transports(5), containers-auth.json(5)
|
302
packages/system/virt/src/buildah/buildahdocs/buildah-config.1.md
Normal file
302
packages/system/virt/src/buildah/buildahdocs/buildah-config.1.md
Normal file
@@ -0,0 +1,302 @@
|
||||
# buildah-config "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-config - Update image configuration settings.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah config** [*options*] *container*
|
||||
|
||||
## DESCRIPTION
|
||||
Updates one or more of the settings kept for a container.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--add-history**
|
||||
|
||||
Add an entry to the image's history which will note changes to the settings for
|
||||
**--cmd**, **--entrypoint**, **--env**, **--healthcheck**, **--label**,
|
||||
**--onbuild**, **--port**, **--shell**, **--stop-signal**, **--user**,
|
||||
**--volume**, and **--workingdir**.
|
||||
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`
|
||||
|
||||
**--annotation**, **-a** *annotation*=*annotation*
|
||||
|
||||
Add an image *annotation* (e.g. annotation=*annotation*) to the image manifest
|
||||
of any images which will be built using the specified container. Can be used multiple times.
|
||||
If *annotation* has a trailing `-`, then the *annotation* is removed from the config.
|
||||
If the *annotation* is set to "-" then all annotations are removed from the config.
|
||||
|
||||
**--arch** *architecture*
|
||||
|
||||
Set the target *architecture* for any images which will be built using the
|
||||
specified container. By default, if the container was based on an image, that
|
||||
image's target architecture is kept, otherwise the host's architecture is
|
||||
recorded.
|
||||
|
||||
**--author** *author*
|
||||
|
||||
Set contact information for the *author* for any images which will be built
|
||||
using the specified container.
|
||||
|
||||
**--cmd** *command*
|
||||
|
||||
Set the default *command* to run for containers based on any images which will
|
||||
be built using the specified container. When used in combination with an
|
||||
*entry point*, this specifies the default parameters for the *entry point*.
|
||||
|
||||
**--comment** *comment*
|
||||
|
||||
Set the image-level comment for any images which will be built using the
|
||||
specified container.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--created-by** *created*
|
||||
|
||||
Set the description of how the topmost layer was *created* for any images which
|
||||
will be created using the specified container.
|
||||
|
||||
**--domainname** *domain*
|
||||
|
||||
Set the domainname to set when running containers based on any images built
|
||||
using the specified container.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--entrypoint** *"command"* | *'["command", "arg1", ...]'*
|
||||
|
||||
Set the *entry point* for containers based on any images which will be built
|
||||
using the specified container. buildah supports two formats for entrypoint. It
|
||||
can be specified as a simple string, or as an array of commands.
|
||||
|
||||
Note: When the entrypoint is specified as a string, container runtimes will
|
||||
ignore the `cmd` value of the container image. However if you use the array
|
||||
form, then the cmd will be appended onto the end of the entrypoint cmd and be
|
||||
executed together.
|
||||
|
||||
Note: The string form is appended to the `sh -c` command as the entrypoint. The array form
|
||||
replaces entrypoint entirely.
|
||||
|
||||
String Format:
|
||||
```
|
||||
$ buildah from scratch
|
||||
$ buildah config --entrypoint "/usr/bin/notashell" working-container
|
||||
$ buildah inspect --format '{{ .OCIv1.Config.Entrypoint }}' working-container
|
||||
[/bin/sh -c /usr/bin/notshell]
|
||||
$ buildah inspect --format '{{ .Docker.Config.Entrypoint }}' working-container
|
||||
[/bin/sh -c /usr/bin/notshell]
|
||||
```
|
||||
|
||||
Array Format:
|
||||
```
|
||||
$ buildah config --entrypoint '["/usr/bin/notashell"]' working-container
|
||||
$ buildah inspect --format '{{ .OCIv1.Config.Entrypoint }}' working-container
|
||||
[/usr/bin/notashell]
|
||||
$ buildah inspect --format '{{ .Docker.Config.Entrypoint }}' working-container
|
||||
[/usr/bin/notashell]
|
||||
```
|
||||
|
||||
**--env**, **-e** *env[=value]*
|
||||
|
||||
Add a value (e.g. env=*value*) to the environment for containers based on any
|
||||
images which will be built using the specified container. Can be used multiple times.
|
||||
If *env* is named but neither `=` nor a `value` is specified, then the value
|
||||
will be taken from the current process environment.
|
||||
If *env* has a trailing `-`, then the *env* is removed from the config.
|
||||
If the *env* is set to "-" then all environment variables are removed from the config.
|
||||
|
||||
**--healthcheck** *command*
|
||||
|
||||
Specify a command which should be run to check if a container is running correctly.
|
||||
|
||||
Values can be *NONE*, "*CMD* ..." (run the specified command directly), or
|
||||
"*CMD-SHELL* ..." (run the specified command using the system's shell), or the
|
||||
empty value (remove a previously-set value and related settings).
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--healthcheck-interval** *interval*
|
||||
|
||||
Specify how often the command specified using the *--healthcheck* option should
|
||||
be run.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--healthcheck-retries** *count*
|
||||
|
||||
Specify how many times the command specified using the *--healthcheck* option
|
||||
can fail before the container is considered to be unhealthy.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--healthcheck-start-interval** *interval*
|
||||
|
||||
Specify the time between health checks during the start period.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--healthcheck-start-period** *interval*
|
||||
|
||||
Specify how much time can elapse after a container has started before a failure
|
||||
to run the command specified using the *--healthcheck* option should be treated
|
||||
as an indication that the container is failing. During this time period,
|
||||
failures will be attributed to the container not yet having fully started, and
|
||||
will not be counted as errors. After the command succeeds, or the time period
|
||||
has elapsed, failures will be counted as errors.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--healthcheck-timeout** *interval*
|
||||
|
||||
Specify how long to wait after starting the command specified using the
|
||||
*--healthcheck* option to wait for the command to return its exit status. If
|
||||
the command has not returned within this time, it should be considered to have
|
||||
failed.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--history-comment** *comment*
|
||||
|
||||
Sets a comment on the topmost layer in any images which will be created
|
||||
using the specified container.
|
||||
|
||||
**--hostname** *host*
|
||||
|
||||
Set the hostname to set when running containers based on any images built using
|
||||
the specified container.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--label**, **-l** *label*=*value*
|
||||
|
||||
Add an image *label* (e.g. label=*value*) to the image configuration of any
|
||||
images which will be built using the specified container. Can be used multiple times.
|
||||
If *label* has a trailing `-`, then the *label* is removed from the config.
|
||||
If the *label* is set to "-" then all labels are removed from the config.
|
||||
|
||||
**--onbuild** *onbuild command*
|
||||
|
||||
Add an ONBUILD command to the image. ONBUILD commands are automatically run
|
||||
when images are built based on the image you are creating.
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--os** *operating system*
|
||||
|
||||
Set the target *operating system* for any images which will be built using
|
||||
the specified container. By default, if the container was based on an image,
|
||||
its OS is kept, otherwise the host's OS's name is recorded.
|
||||
|
||||
**--os-feature** *feature*
|
||||
|
||||
Set the name of a required operating system *feature* for any images which will
|
||||
be built using the specified container. By default, if the container was based
|
||||
on an image, the base image's required OS feature list is kept, if it specified
|
||||
one. This option is typically only meaningful when the image's OS is Windows.
|
||||
|
||||
If *feature* has a trailing `-`, then the *feature* is removed from the set of
|
||||
required features which will be listed in the image. If the *feature* is set
|
||||
to "-" then the entire features list is removed from the config.
|
||||
|
||||
**--os-version** *version*
|
||||
|
||||
Set the exact required operating system *version* for any images which will be
|
||||
built using the specified container. By default, if the container was based on
|
||||
an image, the base image's required OS version is kept, if it specified one.
|
||||
This option is typically only meaningful when the image's OS is Windows, and is
|
||||
typically set in Windows base images, so using this option is usually
|
||||
unnecessary.
|
||||
|
||||
**--port**, **-p** *port/protocol*
|
||||
|
||||
Add a *port* to expose when running containers based on any images which
|
||||
will be built using the specified container. Can be used multiple times.
|
||||
To specify whether the port listens on TCP or UDP, use "port/protocol".
|
||||
The default is TCP if the protocol is not specified. To expose the port on both TCP and UDP,
|
||||
specify the port option multiple times. If *port* has a trailing `-` and is already set,
|
||||
then the *port* is removed from the configuration. If the port is set to `-` then all exposed
|
||||
ports settings are removed from the configuration.
|
||||
|
||||
**--shell** *shell*
|
||||
|
||||
Set the default *shell* to run inside of the container image.
|
||||
The shell instruction allows the default shell used for the shell form of commands to be overridden. The default shell for Linux containers is "/bin/sh -c".
|
||||
|
||||
Note: this setting is not present in the OCIv1 image format, so it is discarded when writing images using OCIv1 formats.
|
||||
|
||||
**--stop-signal** *signal*
|
||||
|
||||
Set default *stop signal* for container. This signal will be sent when container is stopped, default is SIGINT.
|
||||
|
||||
**--unsetlabel** *label*
|
||||
|
||||
Unset the image label, causing the label not to be inherited from the base image.
|
||||
|
||||
**--user**, **-u** *user*[:*group*]
|
||||
|
||||
Set the default *user* to be used when running containers based on this image.
|
||||
The user can be specified as a user name
|
||||
or UID, optionally followed by a group name or GID, separated by a colon (':').
|
||||
If names are used, the container should include entries for those names in its
|
||||
*/etc/passwd* and */etc/group* files.
|
||||
|
||||
**--variant** *variant*
|
||||
|
||||
Set the target architecture *variant* for any images which will be built using
|
||||
the specified container. By default, if the container was based on an image,
|
||||
that image's target architecture and variant information is kept, otherwise the
|
||||
host's architecture and variant are recorded.
|
||||
|
||||
**--volume**, **-v** *volume*
|
||||
|
||||
Add a location in the directory tree which should be marked as a *volume* in any images which will be built using the specified container. Can be used multiple times. If *volume* has a trailing `-`, and is already set, then the *volume* is removed from the config.
|
||||
If the *volume* is set to "-" then all volumes are removed from the config.
|
||||
|
||||
**--workingdir** *directory*
|
||||
|
||||
Set the initial working *directory* for containers based on images which will
|
||||
be built using the specified container.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah config --author='Jane Austen' --workingdir='/etc/mycontainers' containerID
|
||||
|
||||
buildah config --entrypoint /entrypoint.sh containerID
|
||||
|
||||
buildah config --entrypoint '[ "/entrypoint.sh", "dev" ]' containerID
|
||||
|
||||
buildah config --env foo=bar --env PATH=$PATH containerID
|
||||
|
||||
buildah config --env foo- containerID
|
||||
|
||||
buildah config --label Name=Mycontainer --label Version=1.0 containerID
|
||||
|
||||
buildah config --label Name- containerID
|
||||
|
||||
buildah config --annotation note=myNote containerID
|
||||
|
||||
buildah config --annotation note-
|
||||
|
||||
buildah config --volume /usr/myvol containerID
|
||||
|
||||
buildah config --volume /usr/myvol- containerID
|
||||
|
||||
buildah config --port 1234 --port 8080 containerID
|
||||
|
||||
buildah config --port 514/tcp --port 514/udp containerID
|
||||
|
||||
buildah config --env 1234=5678 containerID
|
||||
|
||||
buildah config --env 1234- containerID
|
||||
|
||||
buildah config --os-version 10.0.19042.1645 containerID
|
||||
|
||||
buildah config --os-feature win32k containerID
|
||||
|
||||
buildah config --os-feature win32k- containerID
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
@@ -0,0 +1,123 @@
|
||||
# buildah-containers "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-containers - List the working containers and their base images.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah containers** [*options*]
|
||||
|
||||
## DESCRIPTION
|
||||
Lists containers which appear to be Buildah working containers, their names and
|
||||
IDs, and the names and IDs of the images from which they were initialized.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
List information about all containers, including those which were not created
|
||||
by and are not being used by Buildah. Containers created by Buildah are
|
||||
denoted with an '*' in the 'BUILDER' column.
|
||||
|
||||
**--filter**, **-f**
|
||||
|
||||
Filter output based on conditions provided.
|
||||
|
||||
Valid filters are listed below:
|
||||
|
||||
| **Filter** | **Description** |
|
||||
| --------------- | ------------------------------------------------------------------- |
|
||||
| id | [ID] Container's ID |
|
||||
| name | [Name] Container's name |
|
||||
| ancestor | [ImageName] Image or descendant used to create container |
|
||||
|
||||
**--format**
|
||||
|
||||
Pretty-print containers using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| **Placeholder** | **Description** |
|
||||
| --------------- | -----------------------------------------|
|
||||
| .ContainerID | Container ID |
|
||||
| .Builder | Whether container was created by buildah |
|
||||
| .ImageID | Image ID |
|
||||
| .ImageName | Image name |
|
||||
| .ContainerName | Container name |
|
||||
|
||||
**--json**
|
||||
|
||||
Output in JSON format.
|
||||
|
||||
**--noheading**, **-n**
|
||||
|
||||
Omit the table headings from the listing of containers.
|
||||
|
||||
**--notruncate**
|
||||
|
||||
Do not truncate IDs and image names in the output.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Displays only the container IDs.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah containers
|
||||
```
|
||||
CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME
|
||||
ccf84de04b80 * 53ce4390f2ad registry.access.redhat.com/ub... ubi8-working-container
|
||||
45be1d806fc5 * 16ea53ea7c65 docker.io/library/busybox:latest busybox-working-container
|
||||
```
|
||||
|
||||
buildah containers --quiet
|
||||
```
|
||||
ccf84de04b80c309ce6586997c79a769033dc4129db903c1882bc24a058438b8
|
||||
45be1d806fc533fcfc2beee77e424d87e5990d3ce9214d6b374677d6630bba07
|
||||
```
|
||||
|
||||
buildah containers -q --noheading --notruncate
|
||||
```
|
||||
ccf84de04b80c309ce6586997c79a769033dc4129db903c1882bc24a058438b8
|
||||
45be1d806fc533fcfc2beee77e424d87e5990d3ce9214d6b374677d6630bba07
|
||||
```
|
||||
|
||||
buildah containers --json
|
||||
```
|
||||
[
|
||||
{
|
||||
"id": "ccf84de04b80c309ce6586997c79a769033dc4129db903c1882bc24a058438b8",
|
||||
"builder": true,
|
||||
"imageid": "53ce4390f2adb1681eb1a90ec8b48c49c015e0a8d336c197637e7f65e365fa9e",
|
||||
"imagename": "registry.access.redhat.com/ubi8:latest",
|
||||
"containername": "ubi8-working-container"
|
||||
},
|
||||
{
|
||||
"id": "45be1d806fc533fcfc2beee77e424d87e5990d3ce9214d6b374677d6630bba07",
|
||||
"builder": true,
|
||||
"imageid": "16ea53ea7c652456803632d67517b78a4f9075a10bfdc4fc6b7b4cbf2bc98497",
|
||||
"imagename": "docker.io/library/busybox:latest",
|
||||
"containername": "busybox-working-container"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
buildah containers --format "{{.ContainerID}} {{.ContainerName}}"
|
||||
```
|
||||
ccf84de04b80c309ce6586997c79a769033dc4129db903c1882bc24a058438b8 ubi8-working-container
|
||||
45be1d806fc533fcfc2beee77e424d87e5990d3ce9214d6b374677d6630bba07 busybox-working-container
|
||||
```
|
||||
|
||||
buildah containers --format "Container ID: {{.ContainerID}}"
|
||||
```
|
||||
Container ID: ccf84de04b80c309ce6586997c79a769033dc4129db903c1882bc24a058438b8
|
||||
Container ID: 45be1d806fc533fcfc2beee77e424d87e5990d3ce9214d6b374677d6630bba07
|
||||
```
|
||||
|
||||
buildah containers --filter ancestor=ubuntu
|
||||
```
|
||||
CONTAINER ID BUILDER IMAGE ID IMAGE NAME CONTAINER NAME
|
||||
fbfd3505376e * 0ff04b2e7b63 docker.io/library/ubuntu:latest ubuntu-working-container
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
169
packages/system/virt/src/buildah/buildahdocs/buildah-copy.1.md
Normal file
169
packages/system/virt/src/buildah/buildahdocs/buildah-copy.1.md
Normal file
@@ -0,0 +1,169 @@
|
||||
# buildah-copy "1" "April 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-copy - Copies the contents of a file, URL, or directory into a container's working directory.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah copy** *container* *src* [[*src* ...] *dest*]
|
||||
|
||||
## 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.
|
||||
|
||||
## 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. `export BUILDAH_HISTORY=true`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
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_.
|
||||
|
||||
**--checksum** *checksum*
|
||||
|
||||
Checksum the source content. The value of *checksum* must be a standard
|
||||
container digest string. Only supported for HTTP sources.
|
||||
|
||||
**--chmod** *permissions*
|
||||
|
||||
Sets the access permissions of the destination content. Accepts the numerical
|
||||
format. If `--from` is not used, defaults to `0755`.
|
||||
|
||||
**--chown** *owner*:*group*
|
||||
|
||||
Sets the user and group ownership of the destination content. If `--from` is
|
||||
not used, defaults to `0:0`.
|
||||
|
||||
**--contextdir** *directory*
|
||||
|
||||
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.
|
||||
|
||||
**--exclude** *pattern*
|
||||
|
||||
Exclude copying files matching the specified pattern. Option can be specified
|
||||
multiple times. See containerignore(5) for supported formats.
|
||||
|
||||
**--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. If `--chown` or `--chmod` are not used, permissions and ownership
|
||||
is preserved.
|
||||
|
||||
**--ignorefile** *file*
|
||||
|
||||
Path to an alternative .containerignore (.dockerignore) file. Requires \-\-contextdir be specified.
|
||||
|
||||
**--parents**
|
||||
|
||||
Preserve leading directories in the paths of items being copied, relative to either the
|
||||
top of the build context, or to the "pivot point", a location in the source path marked
|
||||
by a path component named "." (i.e., where "/./" occurs in the path).
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Refrain from printing a digest of the copied content.
|
||||
|
||||
**--retry** *attempts*
|
||||
|
||||
Number of times to retry in case of failure when performing pull of images from registry.
|
||||
|
||||
Defaults to `3`.
|
||||
|
||||
**--retry-delay** *duration*
|
||||
|
||||
Duration of delay between retry attempts in case of failure when performing pull of images from registry.
|
||||
|
||||
Defaults to `2s`.
|
||||
|
||||
**--tls-verify** *bool-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.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah copy containerID '/myapp/app.conf' '/myapp/app.conf'
|
||||
|
||||
buildah copy --exclude=**/*.md docs containerID 'docs' '/docs'
|
||||
|
||||
buildah copy --parents containerID './x/a.txt' './y/a.txt' '/parents'
|
||||
|
||||
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' /etc
|
||||
|
||||
## FILES
|
||||
|
||||
### .containerignore/.dockerignore
|
||||
|
||||
If the .containerignore/.dockerignore file exists in the context directory,
|
||||
`buildah copy` 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
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), containerignore(5)
|
@@ -0,0 +1,244 @@
|
||||
# Buildah Essential Commands Guide
|
||||
|
||||
Buildah is a command-line tool for building OCI-compatible container images. Unlike other container build tools, Buildah doesn't require a daemon to be running and allows for granular control over the container building process.
|
||||
|
||||
## Creating Containers = BUILD STEP
|
||||
|
||||
### buildah from
|
||||
|
||||
Creates a new working container, either from scratch or using a specified image.
|
||||
|
||||
```bash
|
||||
# Create a container from an image
|
||||
buildah from [options] <image-name>
|
||||
|
||||
# Create a container from scratch
|
||||
buildah from scratch
|
||||
|
||||
# Examples
|
||||
buildah from fedora:latest
|
||||
buildah from docker://ubuntu:22.04
|
||||
buildah from --name my-container alpine:latest
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--name <name>`: Set a name for the container
|
||||
- `--pull`: Pull image policy (missing, always, never, newer)
|
||||
- `--authfile <path>`: Path to authentication file
|
||||
- `--creds <username:password>`: Registry credentials
|
||||
|
||||
## Working with Containers
|
||||
|
||||
### buildah run
|
||||
|
||||
Runs a command inside of the container.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah run [options] <container-id> <command>
|
||||
|
||||
# Examples
|
||||
buildah run my-container yum install -y httpd
|
||||
buildah run my-container -- sh -c "echo 'Hello World' > /etc/motd"
|
||||
buildah run --hostname myhost my-container ps -auxw
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--tty`, `-t`: Allocate a pseudo-TTY
|
||||
- `--env`, `-e <env=value>`: Set environment variables
|
||||
- `--volume`, `-v <host-dir:container-dir:opts>`: Mount a volume
|
||||
- `--workingdir <directory>`: Set the working directory
|
||||
|
||||
### buildah copy
|
||||
|
||||
Copy files from the host into the container.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah copy [options] <container-id> <source> <destination>
|
||||
|
||||
# Examples
|
||||
buildah copy my-container ./app /app
|
||||
buildah copy my-container config.json /etc/myapp/
|
||||
```
|
||||
|
||||
### buildah add
|
||||
|
||||
Add content from a file, URL, or directory to the container.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah add [options] <container-id> <source> <destination>
|
||||
|
||||
# Examples
|
||||
buildah add my-container https://example.com/archive.tar.gz /tmp/
|
||||
buildah add my-container ./local/dir /app/
|
||||
```
|
||||
|
||||
## Configuring Containers
|
||||
|
||||
### buildah config
|
||||
|
||||
Updates container configuration settings.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah config [options] <container-id>
|
||||
|
||||
# Examples
|
||||
buildah config --author="John Doe" my-container
|
||||
buildah config --port 8080 my-container
|
||||
buildah config --env PATH=$PATH my-container
|
||||
buildah config --label version=1.0 my-container
|
||||
buildah config --entrypoint "/entrypoint.sh" my-container
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--author <author>`: Set the author
|
||||
- `--cmd <command>`: Set the default command
|
||||
- `--entrypoint <command>`: Set the entry point
|
||||
- `--env`, `-e <env=value>`: Set environment variables
|
||||
- `--label`, `-l <label=value>`: Add image labels
|
||||
- `--port`, `-p <port>`: Expose ports
|
||||
- `--user`, `-u <user[:group]>`: Set the default user
|
||||
- `--workingdir <directory>`: Set the working directory
|
||||
- `--volume`, `-v <volume>`: Add a volume
|
||||
|
||||
## Building Images
|
||||
|
||||
### buildah commit
|
||||
|
||||
Create an image from a working container.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah commit [options] <container-id> [<image-name>]
|
||||
|
||||
# Examples
|
||||
buildah commit my-container new-image:latest
|
||||
buildah commit --format docker my-container docker.io/username/image:tag
|
||||
buildah commit --rm my-container localhost/myimage:v1.0
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--format`, `-f`: Output format (oci or docker)
|
||||
- `--rm`: Remove the container after committing
|
||||
- `--quiet`, `-q`: Suppress output
|
||||
- `--squash`: Squash all layers into a single layer
|
||||
|
||||
### buildah build
|
||||
|
||||
Build an image using instructions from Containerfiles or Dockerfiles.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah build [options] <context>
|
||||
|
||||
# Examples
|
||||
buildah build .
|
||||
buildah build -t myimage:latest .
|
||||
buildah build -f Containerfile.custom .
|
||||
buildah build --layers --format docker -t username/myapp:1.0 .
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--file`, `-f <Containerfile>`: Path to Containerfile/Dockerfile
|
||||
- `--tag`, `-t <name:tag>`: Tag to apply to the built image
|
||||
- `--layers`: Cache intermediate layers during build
|
||||
- `--pull`: Force pull of newer base images
|
||||
- `--no-cache`: Do not use cache during build
|
||||
- `--build-arg <key=value>`: Set build-time variables
|
||||
- `--format`: Output format (oci or docker)
|
||||
|
||||
## Managing Images
|
||||
|
||||
### buildah images
|
||||
|
||||
List images in local storage.
|
||||
|
||||
```bash
|
||||
buildah images [options]
|
||||
```
|
||||
|
||||
### buildah rmi
|
||||
|
||||
Remove one or more images.
|
||||
|
||||
```bash
|
||||
buildah rmi [options] <image>
|
||||
```
|
||||
|
||||
### buildah push
|
||||
|
||||
Push an image to a registry.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah push [options] <image> [destination]
|
||||
|
||||
# Examples
|
||||
buildah push myimage:latest docker://registry.example.com/myimage:latest
|
||||
buildah push --tls-verify=false localhost/myimage docker://localhost:5000/myimage
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--authfile <path>`: Path to authentication file
|
||||
- `--creds <username:password>`: Registry credentials
|
||||
- `--tls-verify <bool>`: Require HTTPS and verify certificates
|
||||
|
||||
### buildah tag
|
||||
|
||||
Add an additional name to a local image.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah tag <image> <new-name>
|
||||
|
||||
# Example
|
||||
buildah tag localhost/myimage:latest myimage:v1.0
|
||||
```
|
||||
|
||||
### buildah pull
|
||||
|
||||
Pull an image from a registry.
|
||||
|
||||
```bash
|
||||
# Basic syntax
|
||||
buildah pull [options] <image-name>
|
||||
|
||||
# Examples
|
||||
buildah pull docker.io/library/ubuntu:latest
|
||||
buildah pull --tls-verify=false registry.example.com/myimage:latest
|
||||
```
|
||||
|
||||
Important options:
|
||||
- `--authfile <path>`: Path to authentication file
|
||||
- `--creds <username:password>`: Registry credentials
|
||||
- `--tls-verify <bool>`: Require HTTPS and verify certificates
|
||||
|
||||
## Typical Workflow Example
|
||||
|
||||
```bash
|
||||
# Create a container from an existing image
|
||||
container=$(buildah from fedora:latest)
|
||||
|
||||
# Run a command to install software
|
||||
buildah run $container dnf install -y nginx
|
||||
|
||||
# Copy local configuration files to the container
|
||||
buildah copy $container ./nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Configure container metadata
|
||||
buildah config --port 80 $container
|
||||
buildah config --label maintainer="example@example.com" $container
|
||||
buildah config --entrypoint "/usr/sbin/nginx" $container
|
||||
|
||||
# Commit the container to create a new image
|
||||
buildah commit --rm $container my-nginx:latest
|
||||
|
||||
# Or build using a Containerfile
|
||||
buildah build -t my-nginx:latest .
|
||||
|
||||
# Push the image to a registry
|
||||
buildah push my-nginx:latest docker://docker.io/username/my-nginx:latest
|
||||
```
|
758
packages/system/virt/src/buildah/buildahdocs/buildah-from.1.md
Normal file
758
packages/system/virt/src/buildah/buildahdocs/buildah-from.1.md
Normal file
@@ -0,0 +1,758 @@
|
||||
# buildah-from "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-from - Creates a new working container, either from scratch or using a specified image as a starting point.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah from** [*options*] *image*
|
||||
|
||||
## DESCRIPTION
|
||||
Creates a working container based upon the specified image name. If the
|
||||
supplied image name is "scratch" a new empty container is created. Image names
|
||||
use a "transport":"details" format.
|
||||
|
||||
Multiple transports are supported:
|
||||
|
||||
**dir:**_path_
|
||||
An existing local directory _path_ containing the manifest, layer tarballs, and signatures in individual files. This is a non-standardized format, primarily useful for debugging or noninvasive image inspection.
|
||||
|
||||
**docker://**_docker-reference_ (Default)
|
||||
An image in a registry implementing the "Docker Registry HTTP API V2". By default, uses the authorization state in `$XDG_RUNTIME_DIR/containers/auth.json`, which is set using `(buildah login)`. See containers-auth.json(5) for more information. If the authorization state is not found there, `$HOME/.docker/config.json` is checked, which is set using `(docker login)`.
|
||||
If _docker-reference_ does not include a registry name, *localhost* will be consulted first, followed by any registries named in the registries configuration.
|
||||
|
||||
**docker-archive:**_path_
|
||||
An image is retrieved as a `podman load` formatted file.
|
||||
|
||||
**docker-daemon:**_docker-reference_
|
||||
An image _docker-reference_ stored in the docker daemon's internal storage. _docker-reference_ must include either a tag or a digest. Alternatively, when reading images, the format can also be docker-daemon:algo:digest (an image ID).
|
||||
|
||||
**oci:**_path_**:**_tag_**
|
||||
An image tag in a directory compliant with "Open Container Image Layout Specification" at _path_.
|
||||
|
||||
**oci-archive:**_path_**:**_tag_
|
||||
An image _tag_ in a directory compliant with "Open Container Image Layout Specification" at _path_.
|
||||
|
||||
### DEPENDENCIES
|
||||
|
||||
Buildah resolves the path to the registry to pull from by using the /etc/containers/registries.conf
|
||||
file, containers-registries.conf(5). If the `buildah from` command fails with an "image not known" error,
|
||||
first verify that the registries.conf file is installed and configured appropriately.
|
||||
|
||||
## RETURN VALUE
|
||||
The container ID of the container that was created. On error 1 is returned.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--add-host**=[]
|
||||
|
||||
Add a custom host-to-IP mapping (host:ip)
|
||||
|
||||
Add a line to /etc/hosts. The format is hostname:ip. The **--add-host** option can be set multiple times.
|
||||
|
||||
**--arch**="ARCH"
|
||||
|
||||
Set the ARCH of the image to be pulled to the provided value instead of using the architecture of the host. (Examples: arm, arm64, 386, amd64, ppc64le, s390x)
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login`.
|
||||
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--cap-add**=*CAP\_xxx*
|
||||
|
||||
Add the specified capability to the default set of capabilities which will be
|
||||
supplied for subsequent *buildah run* invocations which use this container.
|
||||
Certain capabilities are granted by default; this option can be used to add
|
||||
more.
|
||||
|
||||
**--cap-drop**=*CAP\_xxx*
|
||||
|
||||
Remove the specified capability from the default set of capabilities which will
|
||||
be supplied for subsequent *buildah run* invocations which use this container.
|
||||
The CAP\_CHOWN, CAP\_DAC\_OVERRIDE, CAP\_FOWNER, CAP\_FSETID, CAP\_KILL,
|
||||
CAP\_NET\_BIND\_SERVICE, CAP\_SETFCAP, CAP\_SETGID, CAP\_SETPCAP,
|
||||
and CAP\_SETUID capabilities are granted by default; this option can be used to remove them. The list of default capabilities is managed in containers.conf(5).
|
||||
|
||||
If a capability is specified to both the **--cap-add** and **--cap-drop**
|
||||
options, it will be dropped, regardless of the order in which the options were
|
||||
given.
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--cgroup-parent**=""
|
||||
|
||||
Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
|
||||
|
||||
**--cgroupns** *how*
|
||||
|
||||
Sets the configuration for IPC namespaces when the container is subsequently
|
||||
used for `buildah run`.
|
||||
The configured value can be "" (the empty string) or "private" to indicate
|
||||
that a new cgroup namespace should be created, or it can be "host" to indicate
|
||||
that the cgroup namespace in which `buildah` itself is being run should be reused.
|
||||
|
||||
**--cidfile** *ContainerIDFile*
|
||||
|
||||
Write the container ID to the file.
|
||||
|
||||
**--cpu-period**=*0*
|
||||
|
||||
Limit the CPU CFS (Completely Fair Scheduler) period
|
||||
|
||||
Limit the container's CPU usage. This flag tells the kernel to restrict the container's CPU usage to the period you specify.
|
||||
|
||||
**--cpu-quota**=*0*
|
||||
|
||||
Limit the CPU CFS (Completely Fair Scheduler) quota
|
||||
|
||||
Limit the container's CPU usage. By default, containers run with the full
|
||||
CPU resource. This flag tells the kernel to restrict the container's CPU usage
|
||||
to the quota you specify.
|
||||
|
||||
**--cpu-shares**, **-c**=*0*
|
||||
|
||||
CPU shares (relative weight)
|
||||
|
||||
By default, all containers get the same proportion of CPU cycles. This proportion
|
||||
can be modified by changing the container's CPU share weighting relative
|
||||
to the weighting of all other running containers.
|
||||
|
||||
To modify the proportion from the default of 1024, use the **--cpu-shares**
|
||||
flag to set the weighting to 2 or higher.
|
||||
|
||||
The proportion will only apply when CPU-intensive processes are running.
|
||||
When tasks in one container are idle, other containers can use the
|
||||
left-over CPU time. The actual amount of CPU time will vary depending on
|
||||
the number of containers running on the system.
|
||||
|
||||
For example, consider three containers, one has a cpu-share of 1024 and
|
||||
two others have a cpu-share setting of 512. When processes in all three
|
||||
containers attempt to use 100% of CPU, the first container would receive
|
||||
50% of the total CPU time. If you add a fourth container with a cpu-share
|
||||
of 1024, the first container only gets 33% of the CPU. The remaining containers
|
||||
receive 16.5%, 16.5% and 33% of the CPU.
|
||||
|
||||
On a multi-core system, the shares of CPU time are distributed over all CPU
|
||||
cores. Even if a container is limited to less than 100% of CPU time, it can
|
||||
use 100% of each individual CPU core.
|
||||
|
||||
For example, consider a system with more than three cores. If you start one
|
||||
container **{C0}** with **-c=512** running one process, and another container
|
||||
**{C1}** with **-c=1024** running two processes, this can result in the following
|
||||
division of CPU shares:
|
||||
|
||||
PID container CPU CPU share
|
||||
100 {C0} 0 100% of CPU0
|
||||
101 {C1} 1 100% of CPU1
|
||||
102 {C1} 2 100% of CPU2
|
||||
|
||||
**--cpuset-cpus**=""
|
||||
|
||||
CPUs in which to allow execution (0-3, 0,1)
|
||||
|
||||
**--cpuset-mems**=""
|
||||
|
||||
Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
|
||||
|
||||
If you have four memory nodes on your system (0-3), use `--cpuset-mems=0,1`
|
||||
then processes in your container will only use memory from the first
|
||||
two memory nodes.
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--decryption-key** *key[:passphrase]*
|
||||
|
||||
The [key[:passphrase]] to be used for decryption of images. Key can point to keys and/or certificates. Decryption will be tried with all keys. If the key is protected by a passphrase, it is required to be passed in the argument and omitted otherwise.
|
||||
|
||||
**--device**=*device*
|
||||
|
||||
Add a host device, or devices under a directory, to the environment of
|
||||
subsequent **buildah run** invocations for the new working container. The
|
||||
optional *permissions* parameter can be used to specify device permissions,
|
||||
using any one or more of **r** for read, **w** for write, and **m** for
|
||||
**mknod**(2).
|
||||
|
||||
Example: **--device=/dev/sdc:/dev/xvdc:rwm**.
|
||||
|
||||
Note: if _host-device_ is a symbolic link then it will be resolved first.
|
||||
The container will only store the major and minor numbers of the host device.
|
||||
|
||||
The device to share can also be specified using a Container Device Interface
|
||||
(CDI) specification (https://github.com/cncf-tags/container-device-interface).
|
||||
|
||||
Note: if the user only has access rights via a group, accessing the device
|
||||
from inside a rootless container will fail. The **crun**(1) runtime offers a
|
||||
workaround for this by adding the option **--annotation run.oci.keep_original_groups=1**.
|
||||
|
||||
**--dns**=[]
|
||||
|
||||
Set custom DNS servers
|
||||
|
||||
This option can be used to override the DNS configuration passed to the container. Typically this is necessary when the host DNS configuration is invalid for the container (e.g., 127.0.0.1). When this is the case the `--dns` flag is necessary for every run.
|
||||
|
||||
The special value **none** can be specified to disable creation of /etc/resolv.conf in the container by Buildah. The /etc/resolv.conf file in the image will be used without changes.
|
||||
|
||||
**--dns-option**=[]
|
||||
|
||||
Set custom DNS options
|
||||
|
||||
**--dns-search**=[]
|
||||
|
||||
Set custom DNS search domains
|
||||
|
||||
**--format**, **-f** *oci* | *docker*
|
||||
|
||||
Control the format for the built image's 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).
|
||||
|
||||
Note: You can also override the default format by setting the BUILDAH\_FORMAT
|
||||
environment variable. `export BUILDAH_FORMAT=docker`
|
||||
|
||||
**--group-add**=*group* | *keep-groups*
|
||||
|
||||
Assign additional groups to the primary user running within the container
|
||||
process.
|
||||
|
||||
- `keep-groups` is a special flag that tells Buildah to keep the supplementary
|
||||
group access.
|
||||
|
||||
Allows container to use the user's supplementary group access. If file systems
|
||||
or devices are only accessible by the rootless user's group, this flag tells the
|
||||
OCI runtime to pass the group access into the container. Currently only
|
||||
available with the `crun` OCI runtime. Note: `keep-groups` is exclusive, other
|
||||
groups cannot be specified with this flag.
|
||||
|
||||
**--http-proxy**
|
||||
|
||||
By default proxy environment variables are passed into the container if set
|
||||
for the Buildah process. This can be disabled by setting the `--http-proxy`
|
||||
option to `false`. The environment variables passed in include `http_proxy`,
|
||||
`https_proxy`, `ftp_proxy`, `no_proxy`, and also the upper case versions of
|
||||
those.
|
||||
|
||||
Defaults to `true`
|
||||
|
||||
**--ipc** *how*
|
||||
|
||||
Sets the configuration for IPC namespaces when the container is subsequently
|
||||
used for `buildah run`.
|
||||
The configured value can be "" (the empty string) or "container" to indicate
|
||||
that a new IPC namespace should be created, or it can be "host" to indicate
|
||||
that the IPC namespace in which `Buildah` itself is being run should be reused,
|
||||
or it can be the path to an IPC namespace which is already in use by
|
||||
another process.
|
||||
|
||||
**--isolation** *type*
|
||||
|
||||
Controls what type of isolation is used for running processes under `buildah
|
||||
run`. Recognized types include *oci* (OCI-compatible runtime, the default),
|
||||
*rootless* (OCI-compatible runtime invoked using a modified
|
||||
configuration, with *--no-new-keyring* added to its *create* invocation,
|
||||
reusing the host's network and UTS namespaces, and creating private IPC, PID,
|
||||
mount, and user namespaces; the default for unprivileged users), and *chroot*
|
||||
(an internal wrapper that leans more toward chroot(1) than container
|
||||
technology, reusing the host's control group, network, IPC, and PID namespaces,
|
||||
and creating private mount and UTS namespaces, and creating user namespaces
|
||||
only when they're required for ID mapping).
|
||||
|
||||
Note: You can also override the default isolation type by setting the
|
||||
BUILDAH\_ISOLATION environment variable. `export BUILDAH_ISOLATION=oci`
|
||||
|
||||
**--memory**, **-m**=""
|
||||
|
||||
Memory limit (format: <number>[<unit>], where unit = b, k, m or g)
|
||||
|
||||
Allows you to constrain the memory available to a container. If the host
|
||||
supports swap memory, then the **-m** memory setting can be larger than physical
|
||||
RAM. If a limit of 0 is specified (not using **-m**), the container's memory is
|
||||
not limited. The actual limit may be rounded up to a multiple of the operating
|
||||
system's page size (the value would be very large, that's millions of trillions).
|
||||
|
||||
**--memory-swap**="LIMIT"
|
||||
|
||||
A limit value equal to memory plus swap. Must be used with the **-m**
|
||||
(**--memory**) flag. The swap `LIMIT` should always be larger than **-m**
|
||||
(**--memory**) value. By default, the swap `LIMIT` will be set to double
|
||||
the value of --memory.
|
||||
|
||||
The format of `LIMIT` is `<number>[<unit>]`. Unit can be `b` (bytes),
|
||||
`k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a
|
||||
unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap.
|
||||
|
||||
**--name** *name*
|
||||
|
||||
A *name* for the working container
|
||||
|
||||
**--network**=*mode*, **--net**=*mode*
|
||||
|
||||
Sets the configuration for network namespaces when the container is subsequently
|
||||
used for `buildah run`.
|
||||
|
||||
Valid _mode_ values are:
|
||||
|
||||
- **none**: no networking. Invalid if using **--dns**, **--dns-opt**, or **--dns-search**;
|
||||
- **host**: use the host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure;
|
||||
- **ns:**_path_: path to a network namespace to join;
|
||||
- **private**: create a new namespace for the container (default)
|
||||
- **\<network name|ID\>**: Join the network with the given name or ID, e.g. use `--network mynet` to join the network with the name mynet. Only supported for rootful users.
|
||||
- **slirp4netns[:OPTIONS,...]**: use **slirp4netns**(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options, they can also be set with `network_cmd_options` in containers.conf:
|
||||
- **allow_host_loopback=true|false**: Allow slirp4netns to reach the host loopback IP (default is 10.0.2.2 or the second IP from slirp4netns cidr subnet when changed, see the cidr option below). The default is false.
|
||||
- **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520`).
|
||||
- **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24`).
|
||||
- **enable_ipv6=true|false**: Enable IPv6. Default is true. (Required for `outbound_addr6`).
|
||||
- **outbound_addr=INTERFACE**: Specify the outbound interface slirp binds to (ipv4 traffic only).
|
||||
- **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp binds to.
|
||||
- **outbound_addr6=INTERFACE**: Specify the outbound interface slirp binds to (ipv6 traffic only).
|
||||
- **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp binds to.
|
||||
- **pasta[:OPTIONS,...]**: use **pasta**(1) to create a user-mode networking
|
||||
stack. \
|
||||
This is only supported in rootless mode. \
|
||||
By default, IPv4 and IPv6 addresses and routes, as well as the pod interface
|
||||
name, are copied from the host. If port forwarding isn't configured, ports
|
||||
are forwarded dynamically as services are bound on either side (init
|
||||
namespace or container namespace). Port forwarding preserves the original
|
||||
source IP address. Options described in pasta(1) can be specified as
|
||||
comma-separated arguments. \
|
||||
In terms of pasta(1) options, **--config-net** is given by default, in
|
||||
order to configure networking when the container is started, and
|
||||
**--no-map-gw** is also assumed by default, to avoid direct access from
|
||||
container to host using the gateway address. The latter can be overridden
|
||||
by passing **--map-gw** in the pasta-specific options (despite not being an
|
||||
actual pasta(1) option). \
|
||||
Also, **-t none** and **-u none** are passed to disable
|
||||
automatic port forwarding based on bound ports. Similarly, **-T none** and
|
||||
**-U none** are given to disable the same functionality from container to
|
||||
host. \
|
||||
Some examples:
|
||||
- **pasta:--map-gw**: Allow the container to directly reach the host using the
|
||||
gateway address.
|
||||
- **pasta:--mtu,1500**: Specify a 1500 bytes MTU for the _tap_ interface in
|
||||
the container.
|
||||
- **pasta:--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,-m,1500,--no-ndp,--no-dhcpv6,--no-dhcp**,
|
||||
equivalent to default slirp4netns(1) options: disable IPv6, assign
|
||||
`10.0.2.0/24` to the `tap0` interface in the container, with gateway
|
||||
`10.0.2.3`, enable DNS forwarder reachable at `10.0.2.3`, set MTU to 1500
|
||||
bytes, disable NDP, DHCPv6 and DHCP support.
|
||||
- **pasta:-I,tap0,--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,--no-ndp,--no-dhcpv6,--no-dhcp**,
|
||||
equivalent to default slirp4netns(1) options with Podman overrides: same as
|
||||
above, but leave the MTU to 65520 bytes
|
||||
- **pasta:-t,auto,-u,auto,-T,auto,-U,auto**: enable automatic port forwarding
|
||||
based on observed bound ports from both host and container sides
|
||||
- **pasta:-T,5201**: enable forwarding of TCP port 5201 from container to
|
||||
host, using the loopback interface instead of the tap interface for improved
|
||||
performance
|
||||
|
||||
**--os**="OS"
|
||||
|
||||
Set the OS of the image to be pulled to the provided value instead of using the current operating system of the host.
|
||||
|
||||
**--pid** *how*
|
||||
|
||||
Sets the configuration for PID namespaces when the container is subsequently
|
||||
used for `buildah run`.
|
||||
The configured value can be "" (the empty string) or "container" to indicate
|
||||
that a new PID namespace should be created, or it can be "host" to indicate
|
||||
that the PID namespace in which `Buildah` itself is being run should be reused,
|
||||
or it can be the path to a PID namespace which is already in use by another
|
||||
process.
|
||||
|
||||
**--platform**="OS/ARCH[/VARIANT]"
|
||||
|
||||
Set the OS/ARCH of the image to be pulled
|
||||
to the provided value instead of using the current operating system and
|
||||
architecture of the host (for example `linux/arm`).
|
||||
|
||||
OS/ARCH pairs are those used by the Go Programming Language. In several cases
|
||||
the ARCH value for a platform differs from one produced by other tools such as
|
||||
the `arch` command. Valid OS and architecture name combinations are listed as
|
||||
values for $GOOS and $GOARCH at https://golang.org/doc/install/source#environment,
|
||||
and can also be found by running `go tool dist list`.
|
||||
|
||||
While `buildah from` is happy to pull an image for any platform that exists,
|
||||
`buildah run` will not be able to run binaries provided by that image without
|
||||
the help of emulation provided by packages like `qemu-user-static`.
|
||||
|
||||
**NOTE:** The `--platform` option may not be used in combination with the `--arch`, `--os`, or `--variant` options.
|
||||
|
||||
**--pull**
|
||||
|
||||
Pull image policy. The default is **missing**.
|
||||
|
||||
- **always**: Pull base and SBOM scanner images from the registries listed in
|
||||
registries.conf. Raise an error if a base or SBOM scanner image is not found
|
||||
in the registries, even if an image with the same name is present locally.
|
||||
|
||||
- **missing**: SBOM scanner images only if they could not be found in the local
|
||||
containers storage. Raise an error if no image could be found and the pull
|
||||
fails.
|
||||
|
||||
- **never**: Do not pull base and SBOM scanner images from registries, use only
|
||||
the local versions. Raise an error if the image is not present locally.
|
||||
|
||||
- **newer**: Pull base and SBOM scanner images from the registries listed in
|
||||
registries.conf if newer. Raise an error if a base or SBOM scanner image is
|
||||
not found in the registries when image with the same name is not present
|
||||
locally.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
If an image needs to be pulled from the registry, suppress progress output.
|
||||
|
||||
**--retry** *attempts*
|
||||
|
||||
Number of times to retry in case of failure when performing pull of images from registry.
|
||||
|
||||
Defaults to `3`.
|
||||
|
||||
**--retry-delay** *duration*
|
||||
|
||||
Duration of delay between retry attempts in case of failure when performing pull of images from registry.
|
||||
|
||||
Defaults to `2s`.
|
||||
|
||||
**--security-opt**=[]
|
||||
|
||||
Security Options
|
||||
|
||||
"label=user:USER" : Set the label user for the container
|
||||
"label=role:ROLE" : Set the label role for the container
|
||||
"label=type:TYPE" : Set the label type for the container
|
||||
"label=level:LEVEL" : Set the label level for the container
|
||||
"label=disable" : Turn off label confinement for the container
|
||||
"no-new-privileges" : Not supported
|
||||
|
||||
"seccomp=unconfined" : Turn off seccomp confinement for the container
|
||||
"seccomp=profile.json : White listed syscalls seccomp Json file to be used as a seccomp filter
|
||||
|
||||
"apparmor=unconfined" : Turn off apparmor confinement for the container
|
||||
"apparmor=your-profile" : Set the apparmor confinement profile for the container
|
||||
|
||||
**--shm-size**=""
|
||||
|
||||
Size of `/dev/shm`. The format is `<number><unit>`. `number` must be greater than `0`.
|
||||
Unit is optional and can be `b` (bytes), `k` (kilobytes), `m`(megabytes), or `g` (gigabytes).
|
||||
If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses `64m`.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
**--ulimit** *type*=*soft-limit*[:*hard-limit*]
|
||||
|
||||
Specifies resource limits to apply to processes launched during `buildah run`.
|
||||
This option can be specified multiple times. Recognized resource types
|
||||
include:
|
||||
"core": maximum core dump size (ulimit -c)
|
||||
"cpu": maximum CPU time (ulimit -t)
|
||||
"data": maximum size of a process's data segment (ulimit -d)
|
||||
"fsize": maximum size of new files (ulimit -f)
|
||||
"locks": maximum number of file locks (ulimit -x)
|
||||
"memlock": maximum amount of locked memory (ulimit -l)
|
||||
"msgqueue": maximum amount of data in message queues (ulimit -q)
|
||||
"nice": niceness adjustment (nice -n, ulimit -e)
|
||||
"nofile": maximum number of open files (ulimit -n)
|
||||
"nofile": maximum number of open files (1048576); when run by root
|
||||
"nproc": maximum number of processes (ulimit -u)
|
||||
"nproc": maximum number of processes (1048576); when run by root
|
||||
"rss": maximum size of a process's (ulimit -m)
|
||||
"rtprio": maximum real-time scheduling priority (ulimit -r)
|
||||
"rttime": maximum amount of real-time execution between blocking syscalls
|
||||
"sigpending": maximum number of pending signals (ulimit -i)
|
||||
"stack": maximum stack size (ulimit -s)
|
||||
|
||||
**--userns** *how*
|
||||
|
||||
Sets the configuration for user namespaces when the container is subsequently
|
||||
used for `buildah run`.
|
||||
The configured value can be "" (the empty string) or "container" to indicate
|
||||
that a new user namespace should be created, it can be "host" to indicate that
|
||||
the user namespace in which `Buildah` itself is being run should be reused, or
|
||||
it can be the path to an user namespace which is already in use by another
|
||||
process.
|
||||
|
||||
**--userns-gid-map** *mapping*
|
||||
|
||||
Directly specifies a GID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the working container's contents.
|
||||
Commands run when handling `RUN` instructions will default to being run in
|
||||
their own user namespaces, configured using the UID and GID maps.
|
||||
|
||||
Entries in this map take the form of one or more colon-separated triples of a starting
|
||||
in-container GID, a corresponding starting host-level GID, and the number of
|
||||
consecutive IDs which the map entry represents.
|
||||
|
||||
This option overrides the *remap-gids* setting in the *options* section of
|
||||
/etc/containers/storage.conf.
|
||||
|
||||
If this option is not specified, but a global --userns-gid-map setting is
|
||||
supplied, settings from the global option will be used.
|
||||
|
||||
**--userns-gid-map-group** *mapping*
|
||||
|
||||
Directly specifies a GID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the container's contents.
|
||||
Commands run using `buildah run` will default to being run in their own user
|
||||
namespaces, configured using the UID and GID maps.
|
||||
|
||||
Entries in this map take the form of one or more triples of a starting
|
||||
in-container GID, a corresponding starting host-level GID, and the number of
|
||||
consecutive IDs which the map entry represents.
|
||||
|
||||
This option overrides the *remap-gids* setting in the *options* section of
|
||||
/etc/containers/storage.conf.
|
||||
|
||||
If this option is not specified, but a global --userns-gid-map setting is
|
||||
supplied, settings from the global option will be used.
|
||||
|
||||
If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-gid-map
|
||||
are specified, but --userns-uid-map is specified, the GID map will be set to
|
||||
use the same numeric values as the UID map.
|
||||
|
||||
**NOTE:** When this option is specified by a rootless user, the specified mappings are relative to the rootless usernamespace in the container, rather than being relative to the host as it would be when run rootful.
|
||||
|
||||
**--userns-gid-map-group** *group*
|
||||
|
||||
Specifies that a GID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the container's contents, can be found in entries in the
|
||||
`/etc/subgid` file which correspond to the specified group.
|
||||
Commands run using `buildah run` will default to being run in their own user
|
||||
namespaces, configured using the UID and GID maps.
|
||||
If --userns-uid-map-user is specified, but --userns-gid-map-group is not
|
||||
specified, `Buildah` will assume that the specified user name is also a
|
||||
suitable group name to use as the default setting for this option.
|
||||
|
||||
**--userns-uid-map** *mapping*
|
||||
|
||||
Directly specifies a UID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the working container's contents.
|
||||
Commands run when handling `RUN` instructions will default to being run in
|
||||
their own user namespaces, configured using the UID and GID maps.
|
||||
|
||||
Entries in this map take the form of one or more colon-separated triples of a starting
|
||||
in-container UID, a corresponding starting host-level UID, and the number of
|
||||
consecutive IDs which the map entry represents.
|
||||
|
||||
This option overrides the *remap-uids* setting in the *options* section of
|
||||
/etc/containers/storage.conf.
|
||||
|
||||
If this option is not specified, but a global --userns-uid-map setting is
|
||||
supplied, settings from the global option will be used.
|
||||
|
||||
**--userns-uid-map-user** *mapping*
|
||||
|
||||
Directly specifies a UID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the container's contents.
|
||||
Commands run using `buildah run` will default to being run in their own user
|
||||
namespaces, configured using the UID and GID maps.
|
||||
|
||||
Entries in this map take the form of one or more triples of a starting
|
||||
in-container UID, a corresponding starting host-level UID, and the number of
|
||||
consecutive IDs which the map entry represents.
|
||||
|
||||
This option overrides the *remap-uids* setting in the *options* section of
|
||||
/etc/containers/storage.conf.
|
||||
|
||||
If this option is not specified, but a global --userns-uid-map setting is
|
||||
supplied, settings from the global option will be used.
|
||||
|
||||
If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-uid-map
|
||||
are specified, but --userns-gid-map is specified, the UID map will be set to
|
||||
use the same numeric values as the GID map.
|
||||
|
||||
**NOTE:** When this option is specified by a rootless user, the specified mappings are relative to the rootless usernamespace in the container, rather than being relative to the host as it would be when run rootful.
|
||||
|
||||
**--userns-uid-map-user** *user*
|
||||
|
||||
Specifies that a UID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the container's contents, can be found in entries in the
|
||||
`/etc/subuid` file which correspond to the specified user.
|
||||
Commands run using `buildah run` will default to being run in their own user
|
||||
namespaces, configured using the UID and GID maps.
|
||||
If --userns-gid-map-group is specified, but --userns-uid-map-user is not
|
||||
specified, `Buildah` will assume that the specified group name is also a
|
||||
suitable user name to use as the default setting for this option.
|
||||
|
||||
**--uts** *how*
|
||||
|
||||
Sets the configuration for UTS namespaces when the container is subsequently
|
||||
used for `buildah run`.
|
||||
The configured value can be "" (the empty string) or "container" to indicate
|
||||
that a new UTS namespace should be created, or it can be "host" to indicate
|
||||
that the UTS namespace in which `Buildah` itself is being run should be reused,
|
||||
or it can be the path to a UTS namespace which is already in use by another
|
||||
process.
|
||||
|
||||
**--variant**=""
|
||||
|
||||
Set the architecture variant of the image to be pulled.
|
||||
|
||||
**--volume**, **-v**[=*[HOST-DIR:CONTAINER-DIR[:OPTIONS]]*]
|
||||
|
||||
Create a bind mount. If you specify, ` -v /HOST-DIR:/CONTAINER-DIR`, Buildah
|
||||
bind mounts `/HOST-DIR` in the host to `/CONTAINER-DIR` in the Buildah
|
||||
container. The `OPTIONS` are a comma delimited list and can be:
|
||||
|
||||
* [rw|ro]
|
||||
* [U]
|
||||
* [z|Z|O]
|
||||
* [`[r]shared`|`[r]slave`|`[r]private`|`[r]unbindable`] <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
The `CONTAINER-DIR` must be an absolute path such as `/src/docs`. The `HOST-DIR`
|
||||
must be an absolute path as well. Buildah bind-mounts the `HOST-DIR` to the
|
||||
path you specify. For example, if you supply `/foo` as the host path,
|
||||
Buildah copies the contents of `/foo` to the container filesystem on the host
|
||||
and bind mounts that into the container.
|
||||
|
||||
You can specify multiple **-v** options to mount one or more mounts to a
|
||||
container.
|
||||
|
||||
`Write Protected Volume Mounts`
|
||||
|
||||
You can add the `:ro` or `:rw` suffix to a volume to mount it read-only or
|
||||
read-write mode, respectively. By default, the volumes are mounted read-write.
|
||||
See examples.
|
||||
|
||||
`Chowning Volume Mounts`
|
||||
|
||||
By default, Buildah does not change the owner and group of source volume directories mounted into containers. If a container is created in a new user namespace, the UID and GID in the container may correspond to another UID and GID on the host.
|
||||
|
||||
The `:U` suffix tells Buildah to use the correct host UID and GID based on the UID and GID within the container, to change the owner and group of the source volume.
|
||||
|
||||
`Labeling Volume Mounts`
|
||||
|
||||
Labeling systems like SELinux require that proper labels are placed on volume
|
||||
content mounted into a container. Without a label, the security system might
|
||||
prevent the processes running inside the container from using the content. By
|
||||
default, Buildah does not change the labels set by the OS.
|
||||
|
||||
To change a label in the container context, you can add either of two suffixes
|
||||
`:z` or `:Z` to the volume mount. These suffixes tell Buildah to relabel file
|
||||
objects on the shared volumes. The `z` option tells Buildah that two containers
|
||||
share the volume content. As a result, Buildah labels the content with a shared
|
||||
content label. Shared volume labels allow all containers to read/write content.
|
||||
The `Z` option tells Buildah to label the content with a private unshared label.
|
||||
Only the current container can use a private volume.
|
||||
|
||||
`Overlay Volume Mounts`
|
||||
|
||||
The `:O` flag tells Buildah to mount the directory from the host as a temporary storage using the Overlay file system. The `RUN` command containers are allowed to modify contents within the mountpoint and are stored in the container storage in a separate directory. In Overlay FS terms the source directory will be the lower, and the container storage directory will be the upper. Modifications to the mount point are destroyed when the `RUN` command finishes executing, similar to a tmpfs mount point.
|
||||
|
||||
Any subsequent execution of `RUN` commands sees the original source directory content, any changes from previous RUN commands no longer exist.
|
||||
|
||||
One use case of the `overlay` mount is sharing the package cache from the host into the container to allow speeding up builds.
|
||||
|
||||
Note:
|
||||
|
||||
- The `O` flag is not allowed to be specified with the `Z` or `z` flags. Content mounted into the container is labeled with the private label.
|
||||
On SELinux systems, labels in the source directory need to be readable by the container label. If not, SELinux container separation must be disabled for the container to work.
|
||||
- Modification of the directory volume mounted into the container with an overlay mount can cause unexpected failures. It is recommended that you do not modify the directory until the container finishes running.
|
||||
|
||||
By default bind mounted volumes are `private`. That means any mounts done
|
||||
inside container will not be visible on the host and vice versa. This behavior can
|
||||
be changed by specifying a volume mount propagation property.
|
||||
|
||||
When the mount propagation policy is set to `shared`, any mounts completed inside
|
||||
the container on that volume will be visible to both the host and container. When
|
||||
the mount propagation policy is set to `slave`, one way mount propagation is enabled
|
||||
and any mounts completed on the host for that volume will be visible only inside of the container.
|
||||
To control the mount propagation property of the volume use the `:[r]shared`,
|
||||
`:[r]slave`, `[r]private` or `[r]unbindable`propagation flag. The propagation property can
|
||||
be specified only for bind mounted volumes and not for internal volumes or
|
||||
named volumes. For mount propagation to work on the source mount point (the mount point
|
||||
where source dir is mounted on) it has to have the right propagation properties. For
|
||||
shared volumes, the source mount point has to be shared. And for slave volumes,
|
||||
the source mount has to be either shared or slave. <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
Use `df <source-dir>` to determine the source mount and then use
|
||||
`findmnt -o TARGET,PROPAGATION <source-mount-dir>` to determine propagation
|
||||
properties of source mount, if `findmnt` utility is not available, the source mount point
|
||||
can be determined by looking at the mount entry in `/proc/self/mountinfo`. Look
|
||||
at `optional fields` and see if any propagation properties are specified.
|
||||
`shared:X` means the mount is `shared`, `master:X` means the mount is `slave` and if
|
||||
nothing is there that means the mount is `private`. <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
To change propagation properties of a mount point use the `mount` command. For
|
||||
example, to bind mount the source directory `/foo` do
|
||||
`mount --bind /foo /foo` and `mount --make-private --make-shared /foo`. This
|
||||
will convert /foo into a `shared` mount point. The propagation properties of the source
|
||||
mount can be changed directly. For instance if `/` is the source mount for
|
||||
`/foo`, then use `mount --make-shared /` to convert `/` into a `shared` mount.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah from --pull imagename
|
||||
|
||||
buildah from --pull docker://myregistry.example.com/imagename
|
||||
|
||||
buildah from docker-daemon:imagename:imagetag
|
||||
|
||||
buildah from --name mycontainer docker-archive:filename
|
||||
|
||||
buildah from oci-archive:filename
|
||||
|
||||
buildah from --name mycontainer dir:directoryname
|
||||
|
||||
buildah from --pull-always --name "mycontainer" myregistry.example.com/imagename
|
||||
|
||||
buildah from --tls-verify=false myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from --creds=myusername:mypassword --cert-dir ~/auth myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from --authfile=/tmp/auths/myauths.json myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from --memory 40m --cpu-shares 2 --cpuset-cpus 0,2 --security-opt label=level:s0:c100,c200 myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from --ulimit nofile=1024:1028 --cgroup-parent /path/to/cgroup/parent myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from --volume /home/test:/myvol:ro,Z myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from -v /home/test:/myvol:z,U myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from -v /var/lib/yum:/var/lib/yum:O myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah from --arch=arm --variant v7 myregistry/myrepository/imagename:imagetag
|
||||
|
||||
## 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 pulling an image from a registry, if the name of the registry matches any
|
||||
of the items in the `blockedRegistries` list, the image pull attempt is denied.
|
||||
If there are registries in the `allowedRegistries` list, and the registry's
|
||||
name is not in the list, the pull attempt is denied.
|
||||
|
||||
**TMPDIR**
|
||||
The TMPDIR environment variable allows the user to specify where temporary files
|
||||
are stored while pulling and pushing images. Defaults to '/var/tmp'.
|
||||
|
||||
## FILES
|
||||
|
||||
**registries.conf** (`/etc/containers/registries.conf`)
|
||||
|
||||
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.
|
||||
|
||||
**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.
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-pull(1), buildah-login(1), docker-login(1), namespaces(7), pid\_namespaces(7), containers-policy.json(5), containers-registries.conf(5), user\_namespaces(7), containers.conf(5), containers-auth.json(5)
|
||||
|
||||
## FOOTNOTES
|
||||
<a name="Footnote1">1</a>: The Buildah project is committed to inclusivity, a core value of open source. The `master` and `slave` mount propagation terminology used here is problematic and divisive, and should be changed. However, these terms are currently used within the Linux kernel and must be used as-is at this time. When the kernel maintainers rectify this usage, Buildah will follow suit immediately.
|
137
packages/system/virt/src/buildah/buildahdocs/buildah-images.1.md
Normal file
137
packages/system/virt/src/buildah/buildahdocs/buildah-images.1.md
Normal file
@@ -0,0 +1,137 @@
|
||||
# buildah-images "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-images - List images in local storage.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah images** [*options*] [*image*]
|
||||
|
||||
## DESCRIPTION
|
||||
Displays locally stored images, their names, sizes, created date and their IDs.
|
||||
The created date is displayed in the time locale of the local machine.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
Show all images, including intermediate images from a build.
|
||||
|
||||
**--digests**
|
||||
|
||||
Show the image digests.
|
||||
|
||||
**--filter**, **-f**=[]
|
||||
|
||||
Filter output based on conditions provided (default []).
|
||||
|
||||
Filters:
|
||||
|
||||
**after,since=image**
|
||||
Filter on images created since the given image.
|
||||
|
||||
**before=image**
|
||||
Filter on images created before the given image.
|
||||
|
||||
**dangling=true|false**
|
||||
Show dangling images. An images is considered to be dangling if it has no associated names and tags.
|
||||
|
||||
**id=id**
|
||||
Show image with this specific ID.
|
||||
|
||||
**intermediate=true|false**
|
||||
Show intermediate images. An images is considered to be an indermediate image if it is dangling and has no children.
|
||||
|
||||
**label=key[=value]**
|
||||
Filter by images labels key and/or value.
|
||||
|
||||
**readonly=true|false**
|
||||
Show only read only images or Read/Write images. The default is to show both. Read/Only images can be configured by modifying the "additionalimagestores" in the /etc/containers/storage.conf file.
|
||||
|
||||
**reference=reference**
|
||||
Show images matching the specified reference. Wildcards are supported (e.g., "reference=*fedora:3*").
|
||||
|
||||
**--format**="TEMPLATE"
|
||||
|
||||
Pretty-print images using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
| **Placeholder** | **Description** |
|
||||
| --------------- | -----------------------------------------|
|
||||
| .Created | Creation date in epoch time |
|
||||
| .CreatedAt | Creation date Pretty Formatted |
|
||||
| .CreatedAtRaw | Creation date in raw format |
|
||||
| .Digest | Image Digest |
|
||||
| .ID | Image ID |
|
||||
| .Name | Image Name |
|
||||
| .ReadOnly | Indicates if image came from a R/O store |
|
||||
| .Size | Image Size |
|
||||
| .Tag | Image Tag |
|
||||
|
||||
**--history**
|
||||
|
||||
Display the image name history.
|
||||
|
||||
**--json**
|
||||
|
||||
Display the output in JSON format.
|
||||
|
||||
**--no-trunc**
|
||||
|
||||
Do not truncate output.
|
||||
|
||||
**--noheading**, **-n**
|
||||
|
||||
Omit the table headings from the listing of images.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Displays only the image IDs.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah images
|
||||
|
||||
buildah images fedora:latest
|
||||
|
||||
buildah images --json
|
||||
|
||||
buildah images --quiet
|
||||
|
||||
buildah images -q --noheading --no-trunc
|
||||
|
||||
buildah images --quiet fedora:latest
|
||||
|
||||
buildah images --filter dangling=true
|
||||
|
||||
buildah images --format "ImageID: {{.ID}}"
|
||||
|
||||
```
|
||||
$ buildah images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
registry.access.redhat.com/ubi8 latest 53ce4390f2ad 3 weeks ago 233 MB
|
||||
docker.io/library/busybox latest 16ea53ea7c65 3 weeks ago 1.46 MB
|
||||
quay.io/libpod/testimage 20210610 9f9ec7f2fdef 4 months ago 7.99 MB
|
||||
```
|
||||
|
||||
```
|
||||
# buildah images -a
|
||||
IMAGE NAME IMAGE TAG IMAGE ID CREATED AT SIZE
|
||||
registry.access.redhat.com/ubi8 latest 53ce4390f2ad 3 weeks ago 233 MB
|
||||
<none> <none> 8c6e16890c2b Jun 13, 2018 15:52 4.42 MB
|
||||
localhost/test latest c0cfe75da054 Jun 13, 2018 15:52 4.42 MB
|
||||
```
|
||||
|
||||
```
|
||||
# buildah images --format '{{.ID}} {{.CreatedAtRaw}}'
|
||||
3f53bb00af943dfdf815650be70c0fa7b426e56a66f5e3362b47a129d57d5991 2018-12-20 19:21:30.122610396 -0500 EST
|
||||
8e09da8f6701d7cde1526d79e3123b0f1109b78d925dfe9f9bac6d59d702a390 2019-01-08 09:22:52.330623532 -0500 EST
|
||||
```
|
||||
|
||||
```
|
||||
# buildah images --format '{{.ID}} {{.Name}} {{.Digest}} {{.CreatedAt}} {{.Size}} {{.CreatedAtRaw}}'
|
||||
3f53bb00af943dfdf815650be70c0fa7b426e56a66f5e3362b47a129d57d5991 docker.io/library/alpine sha256:3d2e482b82608d153a374df3357c0291589a61cc194ec4a9ca2381073a17f58e Dec 20, 2018 19:21 4.67 MB 2018-12-20 19:21:30.122610396 -0500 EST
|
||||
8e09da8f6701d7cde1526d79e3123b0f1109b78d925dfe9f9bac6d59d702a390 <none> sha256:894532ec56e0205ce68ca7230b00c18aa3c8ee39fcdb310615c60e813057229c Jan 8, 2019 09:22 4.67 MB 2019-01-08 09:22:52.330623532 -0500 EST
|
||||
```
|
||||
## SEE ALSO
|
||||
buildah(1), containers-storage.conf(5)
|
@@ -0,0 +1,73 @@
|
||||
# buildah-info "1" "November 2018" "Buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-info - Display Buildah system information.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah info** [*options*]
|
||||
|
||||
## DESCRIPTION
|
||||
The information displayed pertains to the host and current storage statistics which is useful when reporting issues.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--debug**, **-d**
|
||||
|
||||
Show additional information.
|
||||
|
||||
**--format** *template*
|
||||
|
||||
Use *template* as a Go template when formatting the output.
|
||||
|
||||
## EXAMPLE
|
||||
Run buildah info response:
|
||||
```
|
||||
$ buildah info
|
||||
{
|
||||
"host": {
|
||||
"Distribution": {
|
||||
"distribution": "ubuntu",
|
||||
"version": "18.04"
|
||||
},
|
||||
"MemTotal": 16702980096,
|
||||
"MemFree": 309428224,
|
||||
"SwapFree": 2146693120,
|
||||
"SwapTotal": 2147479552,
|
||||
"arch": "amd64",
|
||||
"cpus": 4,
|
||||
"hostname": "localhost.localdomain",
|
||||
"kernel": "4.15.0-36-generic",
|
||||
"os": "linux",
|
||||
"rootless": false,
|
||||
"uptime": "91h 30m 59.9s (Approximately 3.79 days)"
|
||||
},
|
||||
"store": {
|
||||
"ContainerStore": {
|
||||
"number": 2
|
||||
},
|
||||
"GraphDriverName": "overlay",
|
||||
"GraphOptions": [
|
||||
"overlay.override_kernel_check=true"
|
||||
],
|
||||
"GraphRoot": "/var/lib/containers/storage",
|
||||
"GraphStatus": {
|
||||
"Backing Filesystem": "extfs",
|
||||
"Native Overlay Diff": "true",
|
||||
"Supports d_type": "true"
|
||||
},
|
||||
"ImageStore": {
|
||||
"number": 1
|
||||
},
|
||||
"RunRoot": "/run/containers/storage"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Run buildah info and retrieve only the store information:
|
||||
```
|
||||
$ buildah info --format={{".store"}}
|
||||
map[GraphOptions:[overlay.override_kernel_check=true] GraphStatus:map[Backing Filesystem:extfs Supports d_type:true Native Overlay Diff:true] ImageStore:map[number:1] ContainerStore:map[number:2] GraphRoot:/var/lib/containers/storage RunRoot:/run/containers/storage GraphDriverName:overlay]
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
@@ -0,0 +1,39 @@
|
||||
# buildah-inspect "1" "May 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-inspect - Display information about working containers or images or manifest lists.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah inspect** [*options*] [**--**] *object*
|
||||
|
||||
## DESCRIPTION
|
||||
Prints the low-level information on Buildah object(s) (e.g. container, images, manifest lists) identified by name or ID. By default, this will render all results in a
|
||||
JSON array. If the container, image, or manifest lists have the same name, this will return container JSON for an unspecified type. If a format is specified,
|
||||
the given template will be executed for each result.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--format**, **-f** *template*
|
||||
|
||||
Use *template* as a Go template when formatting the output.
|
||||
|
||||
Users of this option should be familiar with the [*text/template*
|
||||
package](https://golang.org/pkg/text/template/) in the Go standard library, and
|
||||
of internals of Buildah's implementation.
|
||||
|
||||
**--type**, **-t** **container** | **image** | **manifest**
|
||||
|
||||
Specify whether *object* is a container, image or a manifest list.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah inspect containerID
|
||||
|
||||
buildah inspect --type container containerID
|
||||
|
||||
buildah inspect --type image imageID
|
||||
|
||||
buildah inspect --format '{{.OCIv1.Config.Env}}' alpine
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
114
packages/system/virt/src/buildah/buildahdocs/buildah-login.1.md
Normal file
114
packages/system/virt/src/buildah/buildahdocs/buildah-login.1.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# buildah-login "1" "Apr 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-login - Login to a container registry
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah login** [*options*] *registry*
|
||||
|
||||
## DESCRIPTION
|
||||
**buildah login** logs into a specified registry server with the correct username
|
||||
and password. **buildah login** reads in the username and password from STDIN.
|
||||
The username and password can also be set using the **username** and **password** flags.
|
||||
The path of the authentication file can be specified by the user by setting the **authfile**
|
||||
flag. The default path used is **${XDG\_RUNTIME_DIR}/containers/auth.json**. If XDG_RUNTIME_DIR
|
||||
is not set, the default is /run/user/$UID/containers/auth.json.
|
||||
|
||||
**buildah [GLOBAL OPTIONS]**
|
||||
|
||||
**buildah login [GLOBAL OPTIONS]**
|
||||
|
||||
**buildah login [OPTIONS] REGISTRY [GLOBAL OPTIONS]**
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--authfile**
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login`.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--compat-auth-file**=*path*
|
||||
|
||||
Instead of updating the default credentials file, update the one at *path*, and use a Docker-compatible format.
|
||||
|
||||
**--get-login**
|
||||
|
||||
Return the logged-in user for the registry. Return error if no login is found.
|
||||
|
||||
**--help**, **-h**
|
||||
|
||||
Print usage statement
|
||||
|
||||
**--password**, **-p**
|
||||
|
||||
Password for registry
|
||||
|
||||
**--password-stdin**
|
||||
|
||||
Take the password from stdin
|
||||
|
||||
**--tls-verify**
|
||||
|
||||
Require HTTPS and verification of certificates when talking to container registries (default: true). If explicitly set to true,
|
||||
then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified,
|
||||
TLS verification will be used unless the target registry is listed as an insecure registry in registries.conf.
|
||||
TLS verification cannot be used when talking to an insecure registry.
|
||||
|
||||
**--username**, **-u**
|
||||
|
||||
Username for registry
|
||||
|
||||
**--verbose**, **-v**
|
||||
|
||||
print detailed information about credential store
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```
|
||||
$ buildah login quay.io
|
||||
Username: qiwanredhat
|
||||
Password:
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah login -u testuser -p testpassword localhost:5000
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah login --authfile ./auth.json quay.io
|
||||
Username: qiwanredhat
|
||||
Password:
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah login --tls-verify=false -u test -p test localhost:5000
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah login --cert-dir /etc/containers/certs.d/ -u foo -p bar localhost:5000
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah login -u testuser --password-stdin < pw.txt quay.io
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
```
|
||||
$ echo $testpassword | buildah login -u testuser --password-stdin quay.io
|
||||
Login Succeeded!
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-logout(1), containers-auth.json(5)
|
@@ -0,0 +1,60 @@
|
||||
# buildah-logout "1" "Apr 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-logout - Logout of a container registry
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah logout** [*options*] *registry*
|
||||
|
||||
## DESCRIPTION
|
||||
**buildah logout** logs out of a specified registry server by deleting the cached credentials
|
||||
stored in the **auth.json** file. The path of the authentication file can be overridden by the user by setting the **authfile** flag.
|
||||
The default path used is **${XDG\_RUNTIME_DIR}/containers/auth.json**. See containers-auth.json(5) for more information.
|
||||
All the cached credentials can be removed by setting the **all** flag.
|
||||
|
||||
**buildah [GLOBAL OPTIONS]**
|
||||
|
||||
**buildah logout [GLOBAL OPTIONS]**
|
||||
|
||||
**buildah logout [OPTIONS] REGISTRY [GLOBAL OPTIONS]**
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
Remove the cached credentials for all registries in the auth file
|
||||
|
||||
**--authfile**
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--compat-auth-file**=*path*
|
||||
|
||||
Instead of updating the default credentials file, update the one at *path*, and use a Docker-compatible format.
|
||||
|
||||
**--help**, **-h**
|
||||
|
||||
Print usage statement
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```
|
||||
$ buildah logout quay.io
|
||||
Removed login credentials for quay.io
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah logout --authfile authdir/myauths.json quay.io
|
||||
Removed login credentials for quay.io
|
||||
```
|
||||
|
||||
```
|
||||
$ buildah logout --all
|
||||
Remove login credentials for all registries
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-login(1), containers-auth.json(5)
|
@@ -0,0 +1,170 @@
|
||||
# buildah-manifest-add "1" "September 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-manifest\-add - Add an image or artifact to a manifest list or image index.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah manifest add** [options...] *listNameOrIndexName* *imageOrArtifactName* [...]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Adds the specified image to the specified manifest list or image index, or
|
||||
creates an artifact manifest and adds it to the specified image index.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
The list image's ID and the digest of the image's manifest.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**
|
||||
|
||||
If the image which should be added to the list or index is itself a list or
|
||||
index, add all of the contents to the local list. By default, only one image
|
||||
from such a list or index will be added to the list or index. Combining
|
||||
*--all* with any of the other options described below is NOT recommended.
|
||||
|
||||
**--annotation** *annotation=value*
|
||||
|
||||
Set an annotation on the entry for the newly-added image or artifact manifest.
|
||||
|
||||
**--arch**
|
||||
|
||||
Override the architecture which the list or index records as a requirement for
|
||||
the image. If *imageName* refers to a manifest list or image index, the
|
||||
architecture information will be retrieved from it. Otherwise, it will be
|
||||
retrieved from the image's configuration information.
|
||||
|
||||
**--artifact**
|
||||
|
||||
Create an artifact manifest and add it to the image index. Arguments after the
|
||||
index name will be interpreted as file names rather than as image references.
|
||||
In most scenarios, the **--artifact-type** option should also be specified.
|
||||
|
||||
**--artifact-annotation** *annotation=value*
|
||||
|
||||
When creating an artifact manifest and adding it to the image index, set an
|
||||
annotation in the artifact manifest.
|
||||
|
||||
**--artifact-config** *filename*
|
||||
|
||||
When creating an artifact manifest and adding it to the image index, use the
|
||||
specified file's contents as the configuration blob in the artifact manifest.
|
||||
In most scenarios, leaving the default value, which signifies an empty
|
||||
configuration, unchanged, is the preferred option.
|
||||
|
||||
**--artifact-config-type** *type*
|
||||
|
||||
When creating an artifact manifest and adding it to the image index, use the
|
||||
specified MIME type as the `mediaType` associated with the configuration blob
|
||||
in the artifact manifest. In most scenarios, leaving the default value, which
|
||||
signifies either an empty configuration or the standard OCI configuration type,
|
||||
unchanged, is the preferred option.
|
||||
|
||||
**--artifact-exclude-titles**
|
||||
|
||||
When creating an artifact manifest and adding it to the image index, do not
|
||||
set "org.opencontainers.image.title" annotations equal to the file's basename
|
||||
for each file added to the artifact manifest. Tools which retrieve artifacts
|
||||
from a registry may use these values to choose names for files when saving
|
||||
artifacts to disk, so this option is not recommended unless it is required
|
||||
for interoperability with a particular registry.
|
||||
|
||||
**--artifact-layer-type** *type*
|
||||
|
||||
When creating an artifact manifest and adding it to the image index, use the
|
||||
specified MIME type as the `mediaType` associated with the files' contents. If
|
||||
not specified, guesses based on either the files names or their contents will
|
||||
be made and used, but the option should be specified if certainty is needed.
|
||||
|
||||
**--artifact-subject** *imageName*
|
||||
|
||||
When creating an artifact manifest and adding it to the image index, set the
|
||||
*subject* field in the artifact manifest to mark the artifact manifest as being
|
||||
associated with the specified image in some way. An artifact manifest can only
|
||||
be associated with, at most, one subject.
|
||||
|
||||
**--artifact-type** *type*
|
||||
|
||||
When creating an artifact manifest, use the specified MIME type as the
|
||||
manifest's `artifactType` value instead of the less informative default value.
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login`.
|
||||
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--features**
|
||||
|
||||
Specify the features list which the list or index records as requirements for
|
||||
the image. This option is rarely used.
|
||||
|
||||
**--os**
|
||||
|
||||
Override the OS which the list or index records as a requirement for the image.
|
||||
If *imageName* refers to a manifest list or image index, the OS information
|
||||
will be retrieved from it. Otherwise, it will be retrieved from the image's
|
||||
configuration information.
|
||||
|
||||
**--os-features**
|
||||
|
||||
Specify the OS features list which the list or index records as requirements
|
||||
for the image. This option is rarely used.
|
||||
|
||||
**--os-version**
|
||||
|
||||
Specify the OS version which the list or index records as a requirement for the
|
||||
image. This option is rarely used.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
**--variant**
|
||||
|
||||
Specify the variant which the list or index records for the image. This option
|
||||
is typically used to distinguish between multiple entries which share the same
|
||||
architecture value, but which expect different versions of its instruction set.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah manifest add mylist:v1.11 docker://fedora
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:f81f09918379d5442d20dff82a298f29698197035e737f76e511d5af422cabd7
|
||||
```
|
||||
|
||||
```
|
||||
buildah manifest add --all mylist:v1.11 docker://fedora
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:f81f09918379d5442d20dff82a298f29698197035e737f76e511d5af422cabd7
|
||||
```
|
||||
|
||||
```
|
||||
buildah manifest add --arch arm64 --variant v8 mylist:v1.11 docker://fedora@sha256:c829b1810d2dbb456e74a695fd3847530c8319e5a95dca623e9f1b1b89020d8b
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:c829b1810d2dbb456e74a695fd3847530c8319e5a95dca623e9f1b1b89020d8b
|
||||
```
|
||||
|
||||
```
|
||||
buildah manifest add --artifact --artifact-type application/x-cd-image mylist:v1.11 ./imagefile.iso
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:1768fae728f6f8ff3d0f8c7df409d7f4f0ca5c89b070810bd4aa4a2ed2eca8bb
|
||||
```
|
||||
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-login(1), buildah-manifest(1), buildah-manifest-create(1), buildah-manifest-remove(1), buildah-manifest-annotate(1), buildah-manifest-inspect(1), buildah-manifest-push(1), buildah-rmi(1), docker-login(1), containers-auth.json(5)
|
@@ -0,0 +1,84 @@
|
||||
# buildah-manifest-annotate "1" "September 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-manifest\-annotate - Add and update information about an image or artifact to a manifest list or image index.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah manifest annotate** [options...] *listNameOrIndexName* *imageManifestDigestOrImageOrArtifactName*
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Adds or updates information about an image or artifact included in a manifest list or image index.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
The list image's ID and the digest of the image's manifest.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--annotation** *annotation=value*
|
||||
|
||||
Set an annotation on the entry for the specified image or artifact. If
|
||||
**--index** is also specified, sets the annotation on the entire image index.
|
||||
|
||||
**--arch**
|
||||
|
||||
Override the architecture which the list or index records as a requirement for
|
||||
the image. This is usually automatically retrieved from the image's
|
||||
configuration information, so it is rarely necessary to use this option.
|
||||
|
||||
**--features**
|
||||
|
||||
Specify the features list which the list or index records as requirements for
|
||||
the image. This option is rarely used.
|
||||
|
||||
**--index**
|
||||
|
||||
Treats arguments to the **--annotation** option as annotation values to be set
|
||||
on the image index itself rather than on an entry in the image index. Implied
|
||||
for **--subject**.
|
||||
|
||||
**--os**
|
||||
|
||||
Override the OS which the list or index records as a requirement for the image.
|
||||
This is usually automatically retrieved from the image's configuration
|
||||
information, so it is rarely necessary to use this option.
|
||||
|
||||
**--os-features**
|
||||
|
||||
Specify the OS features list which the list or index records as requirements
|
||||
for the image. This option is rarely used.
|
||||
|
||||
**--os-version**
|
||||
|
||||
Specify the OS version which the list or index records as a requirement for the
|
||||
image. This option is rarely used.
|
||||
|
||||
**--subject** *imageName*
|
||||
|
||||
Set the *subject* field in the image index to mark the image index as being
|
||||
associated with the specified image in some way. An image index can only be
|
||||
associated with, at most, one subject.
|
||||
|
||||
**--variant**
|
||||
|
||||
Specify the variant which the list or index records for the image. This option
|
||||
is typically used to distinguish between multiple entries which share the same
|
||||
architecture value, but which expect different versions of its instruction set.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah manifest annotate --arch arm64 --variant v8 mylist:v1.11 sha256:c829b1810d2dbb456e74a695fd3847530c8319e5a95dca623e9f1b1b89020d8b
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:c829b1810d2dbb456e74a695fd3847530c8319e5a95dca623e9f1b1b89020d8b
|
||||
```
|
||||
|
||||
```
|
||||
buildah manifest annotate --index --annotation food=yummy mylist:v1.11
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:c829b1810d2dbb456e74a695fd3847530c8319e5a95dca623e9f1b1b89020d8b
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-manifest(1), buildah-manifest-create(1), buildah-manifest-add(1), buildah-manifest-remove(1), buildah-manifest-inspect(1), buildah-manifest-push(1), buildah-rmi(1)
|
@@ -0,0 +1,66 @@
|
||||
# buildah-manifest-create "1" "August 2022" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-manifest\-create - Create a manifest list or image index.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah manifest create** [options...] *listNameOrIndexName* [*imageName* ...]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Creates a new manifest list and stores it as an image in local storage using
|
||||
the specified name.
|
||||
|
||||
If additional images are specified, they are added to the newly-created list or
|
||||
index.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
The randomly-generated image ID of the newly-created list or index. The image
|
||||
can be deleted using the *buildah rmi* command.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**
|
||||
|
||||
If any of the images which should be added to the new list or index are
|
||||
themselves lists or indexes, add all of their contents. By default, only one
|
||||
image from such a list will be added to the newly-created list or index.
|
||||
|
||||
**--amend**
|
||||
|
||||
If a manifest list named *listNameOrIndexName* already exists, modify the
|
||||
preexisting list instead of exiting with an error. The contents of
|
||||
*listNameOrIndexName* are not modified if no *imageName*s are given.
|
||||
|
||||
**--annotation** *annotation=value*
|
||||
|
||||
Set an annotation on the newly-created image index.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah manifest create mylist:v1.11
|
||||
941c1259e4b85bebf23580a044e4838aa3c1e627528422c9bf9262ff1661fca9
|
||||
buildah manifest create --amend mylist:v1.11
|
||||
941c1259e4b85bebf23580a044e4838aa3c1e627528422c9bf9262ff1661fca9
|
||||
```
|
||||
|
||||
```
|
||||
buildah manifest create mylist:v1.11 docker://fedora
|
||||
941c1259e4b85bebf23580a044e4838aa3c1e627528422c9bf9262ff1661fca9
|
||||
```
|
||||
|
||||
```
|
||||
buildah manifest create --all mylist:v1.11 docker://fedora
|
||||
941c1259e4b85bebf23580a044e4838aa3c1e627528422c9bf9262ff1661fca9
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-manifest(1), buildah-manifest-add(1), buildah-manifest-remove(1), buildah-manifest-annotate(1), buildah-manifest-inspect(1), buildah-manifest-push(1), buildah-rmi(1)
|
@@ -0,0 +1,40 @@
|
||||
% buildah-manifest-exists(1)
|
||||
|
||||
## NAME
|
||||
buildah\-manifest\-exists - Check if the given manifest list exists in local storage
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah manifest exists** *manifest*
|
||||
|
||||
## DESCRIPTION
|
||||
**buildah manifest exists** checks if a manifest list exists in local storage. Buildah will
|
||||
return an exit code of `0` when the manifest list is found. A `1` will be returned otherwise.
|
||||
An exit code of `125` indicates there was another issue.
|
||||
|
||||
|
||||
## OPTIONS
|
||||
|
||||
#### **--help**, **-h**
|
||||
|
||||
Print usage statement.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
Check if a manifest list called `list1` exists (the manifest list does actually exist).
|
||||
```
|
||||
$ buildah manifest exists list1
|
||||
$ echo $?
|
||||
0
|
||||
$
|
||||
```
|
||||
|
||||
Check if an manifest called `mylist` exists (the manifest list does not actually exist).
|
||||
```
|
||||
$ buildah manifest exists mylist
|
||||
$ echo $?
|
||||
1
|
||||
$
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
**[buildah(1)](buildah.1.md)**, **[buildah-manifest(1)](buildah-manifest.1.md)**
|
@@ -0,0 +1,37 @@
|
||||
# buildah-manifest-inspect "1" "September 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-manifest\-inspect - Display a manifest list or image index.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah manifest inspect** *listNameOrIndexName*
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Displays the manifest list or image index stored using the specified image name.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
A formatted JSON representation of the manifest list or image index.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `buildah login`.
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah manifest inspect mylist:v1.11
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-manifest(1), buildah-manifest-create(1), buildah-manifest-add(1), buildah-manifest-remove(1), buildah-manifest-annotate(1), buildah-manifest-push(1), buildah-rmi(1)
|
@@ -0,0 +1,113 @@
|
||||
# buildah-manifest-push "1" "September 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-manifest\-push - Push a manifest list or image index to a registry.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah manifest push** [options...] *listNameOrIndexName* *transport:details*
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Pushes a manifest list or image index to a registry.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
The list image's ID and the digest of the image's manifest.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--add-compression** *compression*
|
||||
|
||||
Makes sure that requested compression variant for each platform is added to the manifest list keeping original instance
|
||||
intact in the same manifest list. Supported values are (`gzip`, `zstd` and `zstd:chunked`)
|
||||
|
||||
Note: This is different than `--compression` which replaces the instance with requested with specified compression
|
||||
while `--add-compression` makes sure than each instance has it variant added to manifest list without modifying the
|
||||
original instance.
|
||||
|
||||
**--all**
|
||||
|
||||
Push the images mentioned in the manifest list or image index, in addition to
|
||||
the list or index itself. (Default true)
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `buildah login`.
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--compression-format** *format*
|
||||
|
||||
Specifies the compression format to use. Supported values are: `gzip`, `zstd` and `zstd:chunked`.
|
||||
|
||||
**--compression-level** *level*
|
||||
|
||||
Specify the compression level used with the compression.
|
||||
|
||||
Specifies the compression level to use. The value is specific to the compression algorithm used, e.g. for zstd the accepted values are in the range 1-20 (inclusive), while for gzip it is 1-9 (inclusive).
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--digestfile** *Digestfile*
|
||||
|
||||
After copying the image, write the digest of the resulting image to the file.
|
||||
|
||||
**--force-compression**
|
||||
|
||||
If set, push uses the specified compression algorithm even if the destination contains a differently-compressed variant already.
|
||||
Defaults to `true` if `--compression-format` is explicitly specified on the command-line, `false` otherwise.
|
||||
|
||||
**--format**, **-f**
|
||||
|
||||
Manifest list type (oci or v2s2) to use when pushing the list (default is oci).
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Don't output progress information when pushing lists.
|
||||
|
||||
**--remove-signatures**
|
||||
|
||||
Don't copy signatures when pushing images.
|
||||
|
||||
**--retry** *attempts*
|
||||
|
||||
Number of times to retry in case of failure when performing push of images to registry.
|
||||
|
||||
Defaults to `3`.
|
||||
|
||||
**--retry-delay** *duration*
|
||||
|
||||
Duration of delay between retry attempts in case of failure when performing push of images to registry.
|
||||
|
||||
Defaults to `2s`.
|
||||
|
||||
**--rm**
|
||||
|
||||
Delete the manifest list or image index from local storage if pushing succeeds.
|
||||
|
||||
**--sign-by** *fingerprint*
|
||||
|
||||
Sign the pushed images using the GPG key that matches the specified fingerprint.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah manifest push mylist:v1.11 registry.example.org/mylist:v1.11
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-login(1), buildah-manifest(1), buildah-manifest-create(1), buildah-manifest-add(1), buildah-manifest-remove(1), buildah-manifest-annotate(1), buildah-manifest-inspect(1), buildah-rmi(1), docker-login(1)
|
@@ -0,0 +1,28 @@
|
||||
# buildah-manifest-remove "1" "September 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-manifest\-remove - Remove an image from a manifest list or image index.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah manifest remove** *listNameOrIndexName* *imageNameOrManifestDigestOrArtifactName*
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Removes the image with the specified name or digest from the specified manifest
|
||||
list or image index, or the specified artifact from the specified image index.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
The list image's ID and the digest of the removed image's manifest.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah manifest remove mylist:v1.11 sha256:f81f09918379d5442d20dff82a298f29698197035e737f76e511d5af422cabd7
|
||||
506d8f4bb54931ea03a7e70173a0ed6302e3fb92dfadb3955ba5c17812e95c51: sha256:f81f09918379d5442d20dff82a298f29698197035e737f76e511d5af422cabd7
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-manifest(1), buildah-manifest-create(1), buildah-manifest-add(1), buildah-manifest-annotate(1), buildah-manifest-inspect(1), buildah-manifest-push(1), buildah-rmi(1)
|
@@ -0,0 +1,25 @@
|
||||
# buildah-manifest-rm "1" "April 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-manifest\-rm - Removes one or more manifest lists.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah manifest rm** [*listNameOrIndexName* ...]
|
||||
|
||||
## DESCRIPTION
|
||||
Removes one or more locally stored manifest lists.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah manifest rm <list>
|
||||
|
||||
buildah manifest-rm listID1 listID2
|
||||
|
||||
**storage.conf** (`/etc/containers/storage.conf`)
|
||||
|
||||
storage.conf is the storage configuration file for all tools using containers/storage
|
||||
|
||||
The storage configuration file specifies all of the available container storage options for tools using shared container storage.
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), containers-storage.conf(5), buildah-manifest(1)
|
@@ -0,0 +1,77 @@
|
||||
# buildah-manifest "1" "September 2019" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah-manifest - Create and manipulate manifest lists and image indexes.
|
||||
|
||||
## SYNOPSIS
|
||||
buildah manifest COMMAND [OPTIONS] [ARG...]
|
||||
|
||||
## DESCRIPTION
|
||||
The `buildah manifest` command provides subcommands which can be used to:
|
||||
|
||||
* Create a working Docker manifest list or OCI image index.
|
||||
* Add an entry to a manifest list or image index for a specified image.
|
||||
* Add an entry to an image index for an artifact manifest referring to a file.
|
||||
* Add or update information about an entry in a manifest list or image index.
|
||||
* Delete a working container or an image.
|
||||
* Push a manifest list or image index to a registry or other location.
|
||||
|
||||
## SUBCOMMANDS
|
||||
|
||||
| Command | Man Page | Description |
|
||||
| ------- | -------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
||||
| add | [buildah-manifest-add(1)](buildah-manifest-add.1.md) | Add an image or artifact to a manifest list or image index. |
|
||||
| annotate | [buildah-manifest-annotate(1)](buildah-manifest-annotate.1.md) | Add or update information about an image or artifact in a manifest list or image index. |
|
||||
| create | [buildah-manifest-create(1)](buildah-manifest-create.1.md) | Create a manifest list or image index. |
|
||||
| exists | [buildah-manifest-exists(1)](buildah-manifest-exists.1.md) | Check if a manifest list exists in local storage. |
|
||||
| inspect | [buildah-manifest-inspect(1)](buildah-manifest-inspect.1.md) | Display the contents of a manifest list or image index. |
|
||||
| push | [buildah-manifest-push(1)](buildah-manifest-push.1.md) | Push a manifest list or image index to a registry or other location. |
|
||||
| remove | [buildah-manifest-remove(1)](buildah-manifest-remove.1.md) | Remove an image from a manifest list or image index. |
|
||||
| rm | [buildah-manifest-rm(1)](buildah-manifest-rm.1.md) | Remove manifest list from local storage. |
|
||||
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### Building a multi-arch manifest list from a Containerfile
|
||||
|
||||
Assuming the `Containerfile` uses `RUN` instructions, the host needs
|
||||
a way to execute non-native binaries. Configuring this is beyond
|
||||
the scope of this example. Building a multi-arch manifest list
|
||||
`shazam` in parallel across 4-threads can be done like this:
|
||||
|
||||
$ platarch=linux/amd64,linux/ppc64le,linux/arm64,linux/s390x
|
||||
$ buildah build --jobs=4 --platform=$platarch --manifest shazam .
|
||||
|
||||
**Note:** The `--jobs` argument is optional, and the `--manifest` option
|
||||
should be used instead of the`-t` or `--tag` options.
|
||||
|
||||
### Assembling a multi-arch manifest from separately built images
|
||||
|
||||
Assuming `example.com/example/shazam:$arch` images are built separately
|
||||
on other hosts and pushed to the `example.com` registry. They may
|
||||
be combined into a manifest list, and pushed using a simple loop:
|
||||
|
||||
$ REPO=example.com/example/shazam
|
||||
$ buildah manifest create $REPO:latest
|
||||
$ for IMGTAG in amd64 s390x ppc64le arm64; do \
|
||||
buildah manifest add $REPO:latest docker://$REPO:IMGTAG; \
|
||||
done
|
||||
$ buildah manifest push --all $REPO:latest
|
||||
|
||||
**Note:** The `add` instruction argument order is `<manifest>` then `<image>`.
|
||||
Also, the `--all` push option is required to ensure all contents are
|
||||
pushed, not just the native platform/arch.
|
||||
|
||||
### Removing and tagging a manifest list before pushing
|
||||
|
||||
Special care is needed when removing and pushing manifest lists, as opposed
|
||||
to the contents. You almost always want to use the `manifest rm` and
|
||||
`manifest push --all` subcommands. For example, a rename and push could
|
||||
be performed like this:
|
||||
|
||||
$ buildah tag localhost/shazam example.com/example/shazam
|
||||
$ buildah manifest rm localhost/shazam
|
||||
$ buildah manifest push --all example.com/example/shazam
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-manifest-create(1), buildah-manifest-add(1), buildah-manifest-remove(1), buildah-manifest-annotate(1), buildah-manifest-inspect(1), buildah-manifest-push(1), buildah-manifest-rm(1)
|
@@ -0,0 +1,86 @@
|
||||
# buildah-mkcw "1" "July 2023" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-mkcw - Convert a conventional container image into a confidential workload image.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah mkcw** [*options*] *source* *destination*
|
||||
|
||||
## DESCRIPTION
|
||||
Converts the contents of a container image into a new container image which is
|
||||
suitable for use in a trusted execution environment (TEE), typically run using
|
||||
krun (i.e., crun built with the libkrun feature enabled and invoked as *krun*).
|
||||
Instead of the conventional contents, the root filesystem of the created image
|
||||
will contain an encrypted disk image and configuration information for krun.
|
||||
|
||||
## source
|
||||
A container image, stored locally or in a registry
|
||||
|
||||
## destination
|
||||
A container image, stored locally or in a registry
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--add-file** *source[:destination]*
|
||||
|
||||
Read the contents of the file `source` and add it to the committed image as a
|
||||
file at `destination`. If `destination` is not specified, the path of `source`
|
||||
will be used. The new file will be owned by UID 0, GID 0, have 0644
|
||||
permissions, and be given a current timestamp. This option can be specified
|
||||
multiple times.
|
||||
|
||||
**--attestation-url**, **-u** *url*
|
||||
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 *passphrase* value *must* be specified.
|
||||
|
||||
**--base-image**, **-b** *image*
|
||||
An alternate image to use as the base for the output image. By default,
|
||||
the *scratch* non-image is used.
|
||||
|
||||
**--cpus**, **-c** *number*
|
||||
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.
|
||||
|
||||
**--firmware-library**, **-f** *file*
|
||||
The location of the libkrunfw-sev shared library. If not specified, `buildah`
|
||||
checks for its presence in a number of hard-coded locations.
|
||||
|
||||
**--memory**, **-m** *number*
|
||||
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.
|
||||
|
||||
**--passphrase**, **-p** *text*
|
||||
The passphrase to use to encrypt the disk image which will be included in the
|
||||
container image.
|
||||
If no value is specified, but an *--attestation-url* value is specified, a
|
||||
randomly-generated passphrase will be used.
|
||||
The authors recommend setting an *--attestation-url* but not a *--passphrase*.
|
||||
|
||||
**--slop**, **-s** *{percentage%|sizeKB|sizeMB|sizeGB}*
|
||||
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. If not specified, `buildah` 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.
|
||||
|
||||
**--type**, **-t** {SEV|SNP}
|
||||
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".
|
||||
|
||||
**--workload-id**, **-w** *id*
|
||||
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.
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
@@ -0,0 +1,66 @@
|
||||
# buildah-mount "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-mount - Mount a working container's root filesystem.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah mount** [*container* ...]
|
||||
|
||||
## DESCRIPTION
|
||||
Mounts the specified container's root file system in a location which can be
|
||||
accessed from the host, and returns its location.
|
||||
|
||||
If the mount command is invoked without any arguments, the tool will list all of the currently mounted containers.
|
||||
|
||||
When running in rootless mode, mount runs in a different namespace so
|
||||
that the mounted volume might not be accessible from the host when
|
||||
using a driver different than `vfs`. To be able to access the file
|
||||
system mounted, you might need to create the mount namespace
|
||||
separately as part of `buildah unshare`. In the environment created
|
||||
with `buildah unshare` you can then use `buildah mount` and have
|
||||
access to the mounted file system.
|
||||
|
||||
## RETURN VALUE
|
||||
The location of the mounted file system. On error an empty string and errno is
|
||||
returned.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--json**
|
||||
|
||||
Output in JSON format.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
```
|
||||
buildah mount working-container
|
||||
/var/lib/containers/storage/overlay2/f3ac502d97b5681989dff84dfedc8354239bcecbdc2692f9a639f4e080a02364/merged
|
||||
```
|
||||
|
||||
```
|
||||
buildah mount
|
||||
working-container /var/lib/containers/storage/overlay2/f3ac502d97b5681989dff84dfedc8354239bcecbdc2692f9a639f4e080a02364/merged
|
||||
fedora-working-container /var/lib/containers/storage/overlay2/0ff7d7ca68bed1ace424f9df154d2dd7b5a125c19d887f17653cbcd5b6e30ba1/merged
|
||||
```
|
||||
|
||||
```
|
||||
buildah mount working-container fedora-working-container ubi8-working-container
|
||||
working-container /var/lib/containers/storage/overlay/f8cac5cce73e5102ab321cc5b57c0824035b5cb82b6822e3c86ebaff69fefa9c/merged
|
||||
fedora-working-container /var/lib/containers/storage/overlay/c3ec418be5bda5b72dca74c4d397e05829fe62ecd577dd7518b5f7fc1ca5f491/merged
|
||||
ubi8-working-container /var/lib/containers/storage/overlay/03a071f206f70f4fcae5379bd5126be86b5352dc2a0c3449cd6fca01b77ea868/merged
|
||||
```
|
||||
|
||||
If running in rootless mode, you need to do a buildah unshare first to use
|
||||
the mount point.
|
||||
```
|
||||
$ buildah unshare
|
||||
# buildah mount working-container
|
||||
/var/lib/containers/storage/overlay/f8cac5cce73e5102ab321cc5b57c0824035b5cb82b6822e3c86ebaff69fefa9c/merged
|
||||
# cp foobar /var/lib/containers/storage/overlay/f8cac5cce73e5102ab321cc5b57c0824035b5cb82b6822e3c86ebaff69fefa9c/merged
|
||||
# buildah unmount working-container
|
||||
# exit
|
||||
$ buildah commit working-container newimage
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-unshare(1), buildah-umount(1)
|
@@ -0,0 +1,33 @@
|
||||
# buildah-rmi "1" "Jan 2023" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-prune - Cleanup intermediate images as well as build and mount cache.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah prune**
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Cleanup intermediate images as well as build and mount cache.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
All local images will be removed from the system that do not have containers using the image as a reference image.
|
||||
|
||||
**--force**, **-f**
|
||||
|
||||
This option will cause Buildah to remove all containers that are using the image before removing the image from the system.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah prune
|
||||
|
||||
buildah prune --force
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
buildah(1), containers-registries.conf(5), containers-storage.conf(5)
|
162
packages/system/virt/src/buildah/buildahdocs/buildah-pull.1.md
Normal file
162
packages/system/virt/src/buildah/buildahdocs/buildah-pull.1.md
Normal file
@@ -0,0 +1,162 @@
|
||||
# buildah-pull "1" "July 2018" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-pull - Pull an image from a registry.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah pull** [*options*] *image*
|
||||
|
||||
## DESCRIPTION
|
||||
Pulls an image based upon the specified input. It supports all transports from `containers-transports(5)` (see examples below). If no transport is specified, the input is subject to short-name resolution (see `containers-registries.conf(5)`) and the `docker` (i.e., container registry) transport is used.
|
||||
|
||||
### DEPENDENCIES
|
||||
|
||||
Buildah resolves the path to the registry to pull from by using the /etc/containers/registries.conf
|
||||
file, containers-registries.conf(5). If the `buildah pull` command fails with an "image not known" error,
|
||||
first verify that the registries.conf file is installed and configured appropriately.
|
||||
|
||||
## RETURN VALUE
|
||||
The image ID of the image that was pulled. On error 1 is returned.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all-tags**, **-a**
|
||||
|
||||
All tagged images in the repository will be pulled.
|
||||
|
||||
**--arch**="ARCH"
|
||||
|
||||
Set the ARCH of the image to be pulled to the provided value instead of using the architecture of the host. (Examples: arm, arm64, 386, amd64, ppc64le, s390x)
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login`.
|
||||
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--decryption-key** *key[:passphrase]*
|
||||
|
||||
The [key[:passphrase]] to be used for decryption of images. Key can point to keys and/or certificates. Decryption will be tried with all keys. If the key is protected by a passphrase, it is required to be passed in the argument and omitted otherwise.
|
||||
|
||||
**--os**="OS"
|
||||
|
||||
Set the OS of the image to be pulled instead of using the current operating system of the host.
|
||||
|
||||
**--platform**="OS/ARCH[/VARIANT]"
|
||||
|
||||
Set the OS/ARCH of the image to be pulled
|
||||
to the provided value instead of using the current operating system and
|
||||
architecture of the host (for example `linux/arm`).
|
||||
|
||||
OS/ARCH pairs are those used by the Go Programming Language. In several cases
|
||||
the ARCH value for a platform differs from one produced by other tools such as
|
||||
the `arch` command. Valid OS and architecture name combinations are listed as
|
||||
values for $GOOS and $GOARCH at https://golang.org/doc/install/source#environment,
|
||||
and can also be found by running `go tool dist list`.
|
||||
|
||||
**NOTE:** The `--platform` option may not be used in combination with the `--arch`, `--os`, or `--variant` options.
|
||||
|
||||
**--policy**=**always**|**missing**|**never**|**newer**
|
||||
|
||||
Pull image policy. The default is **missing**.
|
||||
|
||||
- **always**: Always pull the image and throw an error if the pull fails.
|
||||
- **missing**: Pull the image only if it could not be found in the local containers storage. Throw an error if no image could be found and the pull fails.
|
||||
- **never**: Never pull the image but use the one from the local containers storage. Throw an error if no image could be found.
|
||||
- **newer**: Pull if the image on the registry is newer than the one in the local containers storage. An image is considered to be newer when the digests are different. Comparing the time stamps is prone to errors. Pull errors are suppressed if a local image was found.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
If an image needs to be pulled from the registry, suppress progress output.
|
||||
|
||||
**--remove-signatures**
|
||||
|
||||
Don't copy signatures when pulling images.
|
||||
|
||||
**--retry** *attempts*
|
||||
|
||||
Number of times to retry in case of failure when performing pull of images from registry.
|
||||
|
||||
Defaults to `3`.
|
||||
|
||||
**--retry-delay** *duration*
|
||||
|
||||
Duration of delay between retry attempts in case of failure when performing pull of images from registry.
|
||||
|
||||
Defaults to `2s`.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
**--variant**=""
|
||||
|
||||
Set the architecture variant of the image to be pulled.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah pull imagename
|
||||
|
||||
buildah pull docker://myregistry.example.com/imagename
|
||||
|
||||
buildah pull docker-daemon:imagename:imagetag
|
||||
|
||||
buildah pull docker-archive:filename
|
||||
|
||||
buildah pull oci-archive:filename
|
||||
|
||||
buildah pull dir:directoryname
|
||||
|
||||
buildah pull --tls-verify=false myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah pull --creds=myusername:mypassword --cert-dir ~/auth myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah pull --authfile=/tmp/auths/myauths.json myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah pull --arch=aarch64 myregistry/myrepository/imagename:imagetag
|
||||
|
||||
buildah pull --arch=arm --variant=v7 myregistry/myrepository/imagename:imagetag
|
||||
|
||||
## 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 pulling an image from a registry, if the name of the registry matches any
|
||||
of the items in the `blockedRegistries` list, the image pull attempt is denied.
|
||||
If there are registries in the `allowedRegistries` list, and the registry's
|
||||
name is not in the list, the pull attempt is denied.
|
||||
|
||||
**TMPDIR**
|
||||
The TMPDIR environment variable allows the user to specify where temporary files
|
||||
are stored while pulling and pushing images. Defaults to '/var/tmp'.
|
||||
|
||||
## FILES
|
||||
|
||||
**registries.conf** (`/etc/containers/registries.conf`)
|
||||
|
||||
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.
|
||||
|
||||
**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.
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-from(1), buildah-login(1), docker-login(1), containers-policy.json(5), containers-registries.conf(5), containers-transports(5), containers-auth.json(5)
|
185
packages/system/virt/src/buildah/buildahdocs/buildah-push.1.md
Normal file
185
packages/system/virt/src/buildah/buildahdocs/buildah-push.1.md
Normal file
@@ -0,0 +1,185 @@
|
||||
# buildah-push "1" "June 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-push - Push an image, manifest list or image index from local storage to elsewhere.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah push** [*options*] *image* [*destination*]
|
||||
|
||||
## DESCRIPTION
|
||||
Pushes an image from local storage to a specified destination, decompressing
|
||||
and recompessing layers as needed.
|
||||
|
||||
## imageID
|
||||
Image stored in local container/storage
|
||||
|
||||
## DESTINATION
|
||||
|
||||
DESTINATION is the location the container image is pushed to. It supports all transports from `containers-transports(5)` (see examples below). If no transport is specified, the `docker` (i.e., container registry) transport is used.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**
|
||||
|
||||
If specified image is a manifest list or image index, push the images in addition to
|
||||
the list or index itself.
|
||||
|
||||
**--authfile** *path*
|
||||
|
||||
Path of the authentication file. Default is ${XDG_RUNTIME_DIR}/containers/auth.json. See containers-auth.json(5) for more information. This file is created using `buildah login`.
|
||||
|
||||
If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`.
|
||||
|
||||
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
|
||||
environment variable. `export REGISTRY_AUTH_FILE=path`
|
||||
|
||||
**--cert-dir** *path*
|
||||
|
||||
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.
|
||||
The default certificates directory is _/etc/containers/certs.d_.
|
||||
|
||||
**--compression-format** *format*
|
||||
|
||||
Specifies the compression format to use. Supported values are: `gzip`, `zstd` and `zstd:chunked`.
|
||||
`zstd:chunked` is incompatible with encrypting images, and will be treated as `zstd` with a warning in that case.
|
||||
|
||||
**--compression-level** *level*
|
||||
|
||||
Specify the compression level used with the compression.
|
||||
|
||||
Specifies the compression level to use. The value is specific to the compression algorithm used, e.g. for zstd the accepted values are in the range 1-20 (inclusive), while for gzip it is 1-9 (inclusive).
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--digestfile** *Digestfile*
|
||||
|
||||
After copying the image, write the digest of the resulting image to the file.
|
||||
|
||||
**--disable-compression**, **-D**
|
||||
|
||||
Don't compress copies of filesystem layers which will be pushed.
|
||||
|
||||
**--encrypt-layer** *layer(s)*
|
||||
|
||||
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.
|
||||
|
||||
**--encryption-key** *key*
|
||||
|
||||
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.
|
||||
|
||||
**--force-compression**
|
||||
|
||||
If set, push uses the specified compression algorithm even if the destination contains a differently-compressed variant already.
|
||||
Defaults to `true` if `--compression-format` is explicitly specified on the command-line, `false` otherwise.
|
||||
|
||||
**--format**, **-f**
|
||||
|
||||
Manifest Type (oci, v2s2, or v2s1) to use when pushing an image. (default is manifest type of the source image, with fallbacks)
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
When writing the output image, suppress progress output.
|
||||
|
||||
**--remove-signatures**
|
||||
|
||||
Don't copy signatures when pushing images.
|
||||
|
||||
**--retry** *attempts*
|
||||
|
||||
Number of times to retry in case of failure when performing push of images to registry.
|
||||
|
||||
Defaults to `3`.
|
||||
|
||||
**--retry-delay** *duration*
|
||||
|
||||
Duration of delay between retry attempts in case of failure when performing push of images to registry.
|
||||
|
||||
Defaults to `2s`.
|
||||
|
||||
**--rm**
|
||||
|
||||
When pushing a manifest list or image index, delete them from local storage if pushing succeeds.
|
||||
|
||||
**--sign-by** *fingerprint*
|
||||
|
||||
Sign the pushed image using the GPG key that matches the specified fingerprint.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
This example pushes the image specified by the imageID to a local directory in docker format.
|
||||
|
||||
`# buildah push imageID dir:/path/to/image`
|
||||
|
||||
This example pushes the image specified by the imageID to a local directory in oci format.
|
||||
|
||||
`# buildah push imageID oci:/path/to/layout:image:tag`
|
||||
|
||||
This example pushes the image specified by the imageID to a tar archive in oci format.
|
||||
|
||||
`# buildah push imageID oci-archive:/path/to/archive:image:tag`
|
||||
|
||||
This example pushes the image specified by the imageID to a container registry named registry.example.com.
|
||||
|
||||
`# buildah push imageID docker://registry.example.com/repository:tag`
|
||||
|
||||
This example pushes the image specified by the imageID to a container registry named registry.example.com and saves the digest in the specified digestfile.
|
||||
|
||||
`# buildah push --digestfile=/tmp/mydigest imageID docker://registry.example.com/repository:tag`
|
||||
|
||||
This example works like **docker push**, assuming *registry.example.com/my_image* is a local image.
|
||||
|
||||
`# buildah push registry.example.com/my_image`
|
||||
|
||||
This example pushes the image specified by the imageID to a private container registry named registry.example.com with authentication from /tmp/auths/myauths.json.
|
||||
|
||||
`# buildah push --authfile /tmp/auths/myauths.json imageID docker://registry.example.com/repository:tag`
|
||||
|
||||
This example pushes the image specified by the imageID and puts it into the local docker container store.
|
||||
|
||||
`# buildah push imageID docker-daemon:image:tag`
|
||||
|
||||
This example pushes the image specified by the imageID and puts it into the registry on the localhost while turning off tls verification.
|
||||
`# buildah push --tls-verify=false imageID localhost:5000/my-imageID`
|
||||
|
||||
This example pushes the image specified by the imageID and puts it into the registry on the localhost using credentials and certificates for authentication.
|
||||
`# buildah push --cert-dir ~/auth --tls-verify=true --creds=username:password imageID localhost:5000/my-imageID`
|
||||
|
||||
## 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 pushing an image to a registry, if the portion of the destination image
|
||||
name that corresponds to a registry is compared to the items in the
|
||||
`blockedRegistries` list, and if it matches any of them, the push 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
|
||||
push attempt is denied.
|
||||
|
||||
**TMPDIR**
|
||||
The TMPDIR environment variable allows the user to specify where temporary files
|
||||
are stored while pulling and pushing images. Defaults to '/var/tmp'.
|
||||
|
||||
## FILES
|
||||
|
||||
**registries.conf** (`/etc/containers/registries.conf`)
|
||||
|
||||
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.
|
||||
|
||||
**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.
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-login(1), containers-policy.json(5), docker-login(1), containers-registries.conf(5), buildah-manifest(1), containers-transports(5), containers-auth.json(5)
|
@@ -0,0 +1,19 @@
|
||||
# buildah-rename "1" "July 2018" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-rename - Rename a local container.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah rename** *container* *new-name*
|
||||
|
||||
## DESCRIPTION
|
||||
Rename a local container.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah rename containerName NewName
|
||||
|
||||
buildah rename containerID NewName
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
27
packages/system/virt/src/buildah/buildahdocs/buildah-rm.1.md
Normal file
27
packages/system/virt/src/buildah/buildahdocs/buildah-rm.1.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# buildah-rm "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-rm - Removes one or more working containers.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah rm** [*container* ...]
|
||||
|
||||
## DESCRIPTION
|
||||
Removes one or more working containers, unmounting them if necessary.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
All Buildah containers will be removed. Buildah containers are denoted with an '*' in the 'BUILDER' column listed by the command 'buildah containers'.A container name or id cannot be provided when this option is used.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah rm containerID
|
||||
|
||||
buildah rm containerID1 containerID2 containerID3
|
||||
|
||||
buildah rm --all
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
@@ -0,0 +1,77 @@
|
||||
# buildah-rmi "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
|
||||
buildah\-rmi - Removes one or more images.
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**buildah rmi** [*image* ...]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Removes one or more locally stored images.
|
||||
Passing an argument _image_ deletes it, along with any of its dangling (untagged) parent images.
|
||||
|
||||
## LIMITATIONS
|
||||
|
||||
* If the image was pushed to a directory path using the 'dir:' transport,
|
||||
the rmi command can not remove the image. Instead, standard file system
|
||||
commands should be used.
|
||||
|
||||
* If _imageID_ is a name, but does not include a registry name, buildah will
|
||||
attempt to find and remove the named image using the registry name _localhost_,
|
||||
if no such image is found, it will search for the intended image by attempting
|
||||
to expand the given name using the names of registries provided in the system's
|
||||
registries configuration file, registries.conf.
|
||||
|
||||
* If the _imageID_ refers to a *manifest list* or *image index*, this command
|
||||
will ***not*** do what you expect! This command will remove the images
|
||||
associated with the *manifest list* or *index* (not the manifest list/image index
|
||||
itself). To remove that, use the `buildah manifest rm` subcommand instead.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
All local images will be removed from the system that do not have containers using the image as a reference image.
|
||||
An image name or id cannot be provided when this option is used. Read/Only images configured by modifying the "additionalimagestores" in the /etc/containers/storage.conf file, can not be removed.
|
||||
|
||||
**--force**, **-f**
|
||||
|
||||
This option will cause Buildah to remove all containers that are using the image before removing the image from the system.
|
||||
|
||||
**--prune**, **-p**
|
||||
|
||||
All local images will be removed from the system that do not have a tag and do not have a child image pointing to them.
|
||||
An image name or id cannot be provided when this option is used.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah rmi imageID
|
||||
|
||||
buildah rmi --all
|
||||
|
||||
buildah rmi --all --force
|
||||
|
||||
buildah rmi --prune
|
||||
|
||||
buildah rmi --force imageID
|
||||
|
||||
buildah rmi imageID1 imageID2 imageID3
|
||||
|
||||
## Files
|
||||
|
||||
**registries.conf** (`/etc/containers/registries.conf`)
|
||||
|
||||
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.
|
||||
|
||||
**storage.conf** (`/etc/containers/storage.conf`)
|
||||
|
||||
storage.conf is the storage configuration file for all tools using containers/storage
|
||||
|
||||
The storage configuration file specifies all of the available container storage options for tools using shared container storage.
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
buildah(1), containers-registries.conf(5), containers-storage.conf(5)
|
424
packages/system/virt/src/buildah/buildahdocs/buildah-run.1.md
Normal file
424
packages/system/virt/src/buildah/buildahdocs/buildah-run.1.md
Normal file
@@ -0,0 +1,424 @@
|
||||
# buildah-run "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-run - Run a command inside of the container.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah run** [*options*] [**--**] *container* *command*
|
||||
|
||||
## DESCRIPTION
|
||||
Launches a container and runs the specified command in that container using the
|
||||
container's root filesystem as a root filesystem, using configuration settings
|
||||
inherited from the container's image or as specified using previous calls to
|
||||
the *buildah config* command. To execute *buildah run* within an
|
||||
interactive shell, specify the --tty option.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--add-history**
|
||||
|
||||
Add an entry to the history which will note what command is being invoked.
|
||||
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`
|
||||
|
||||
**--cap-add**=*CAP\_xxx*
|
||||
|
||||
Add the specified capability to the set of capabilities which will be granted
|
||||
to the specified command.
|
||||
Certain capabilities are granted by default; this option can be used to add
|
||||
more beyond the defaults, which may have been modified by **--cap-add** and
|
||||
**--cap-drop** options used with the *buildah from* invocation which created
|
||||
the container.
|
||||
|
||||
**--cap-drop**=*CAP\_xxx*
|
||||
|
||||
Drop the specified capability from the set of capabilities which will be granted
|
||||
to the specified command.
|
||||
The CAP\_CHOWN, CAP\_DAC\_OVERRIDE, CAP\_FOWNER,
|
||||
CAP\_FSETID, CAP\_KILL, CAP\_NET\_BIND\_SERVICE, CAP\_SETFCAP,
|
||||
CAP\_SETGID, CAP\_SETPCAP, and CAP\_SETUID capabilities are
|
||||
granted by default; this option can be used to remove them from the defaults,
|
||||
which may have been modified by **--cap-add** and **--cap-drop** options used
|
||||
with the *buildah from* invocation which created the container. The list of default capabilities is managed in containers.conf(5).
|
||||
|
||||
If a capability is specified to both the **--cap-add** and **--cap-drop**
|
||||
options, it will be dropped, regardless of the order in which the options were
|
||||
given.
|
||||
|
||||
**--cgroupns** *how*
|
||||
|
||||
Sets the configuration for the cgroup namespaces for the container.
|
||||
The configured value can be "" (the empty string) or "private" to indicate
|
||||
that a new cgroup namespace should be created, or it can be "host" to indicate
|
||||
that the cgroup namespace in which `buildah` itself is being run should be reused.
|
||||
|
||||
**--contextdir** *directory*
|
||||
|
||||
Allows setting context directory for current RUN invocation. Specifying a context
|
||||
directory causes RUN context to consider context directory as root directory for
|
||||
specified source in `--mount` of type 'bind'.
|
||||
|
||||
**--device**=*device*
|
||||
|
||||
Add a host device, or devices under a directory, to the environment in which
|
||||
the command will be run. The optional *permissions* parameter can be used to
|
||||
specify device permissions, using any one or more of
|
||||
**r** for read, **w** for write, and **m** for **mknod**(2).
|
||||
|
||||
Example: **--device=/dev/sdc:/dev/xvdc:rwm**.
|
||||
|
||||
Note: if _host-device_ is a symbolic link then it will be resolved first.
|
||||
The container will only store the major and minor numbers of the host device.
|
||||
|
||||
The device to share can also be specified using a Container Device Interface
|
||||
(CDI) specification (https://github.com/cncf-tags/container-device-interface).
|
||||
|
||||
Note: if the user only has access rights via a group, accessing the device
|
||||
from inside a rootless container will fail. The **crun**(1) runtime offers a
|
||||
workaround for this by adding the option **--annotation run.oci.keep_original_groups=1**.
|
||||
|
||||
**--env**, **-e** *env=value*
|
||||
|
||||
Temporarily add a value (e.g. env=*value*) to the environment for the running
|
||||
process. Unlike `buildah config --env`, the environment will not persist to
|
||||
later calls to `buildah run` or to the built image. Can be used multiple times.
|
||||
|
||||
**--hostname**
|
||||
|
||||
Set the hostname inside of the running container.
|
||||
|
||||
**--ipc** *how*
|
||||
|
||||
Sets the configuration for the IPC namespaces for the container.
|
||||
The configured value can be "" (the empty string) or "private" to indicate
|
||||
that a new IPC namespace should be created, or it can be "host" to indicate
|
||||
that the IPC namespace in which `buildah` itself is being run should be reused,
|
||||
or it can be the path to an IPC namespace which is already in use by another
|
||||
process.
|
||||
|
||||
**--isolation** *type*
|
||||
|
||||
Controls what type of isolation is used for running the process. Recognized
|
||||
types include *oci* (OCI-compatible runtime, the default), *rootless*
|
||||
(OCI-compatible runtime invoked using a modified configuration, with
|
||||
*--no-new-keyring* added to its *create* invocation, reusing the host's network
|
||||
and UTS namespaces, and creating private IPC, PID, mount, and user namespaces;
|
||||
the default for unprivileged users), and *chroot* (an internal wrapper that
|
||||
leans more toward chroot(1) than container technology, reusing the host's
|
||||
control group, network, IPC, and PID namespaces, and creating private mount and
|
||||
UTS namespaces, and creating user namespaces only when they're required for ID
|
||||
mapping).
|
||||
|
||||
Note: You can also override the default isolation type by setting the
|
||||
BUILDAH\_ISOLATION environment variable. `export BUILDAH_ISOLATION=oci`
|
||||
|
||||
**--mount**=*type=TYPE,TYPE-SPECIFIC-OPTION[,...]*
|
||||
|
||||
Attach a filesystem mount to the container
|
||||
|
||||
Current supported mount TYPES are bind, cache, secret and tmpfs. Writes to `bind` and `tmpfs` mounts are discarded after the command finishes, while changes to `cache` mounts persist across uses.
|
||||
|
||||
e.g.
|
||||
|
||||
type=bind,source=/path/on/host,destination=/path/in/container
|
||||
|
||||
type=tmpfs,tmpfs-size=512M,destination=/path/in/container
|
||||
|
||||
type=cache,target=/path/in/container
|
||||
|
||||
Common Options:
|
||||
|
||||
· src, source: mount source spec for bind and cache. Mandatory for bind. If `from` is specified, `src` is the subpath in the `from` field.
|
||||
|
||||
· dst, destination, target: location where the command being run should see the content being mounted.
|
||||
|
||||
· ro, read-only: (default true for `type=bind`, false for `type=tmpfs`, `type=cache`).
|
||||
|
||||
Options specific to bind:
|
||||
|
||||
· bind-propagation: shared, slave, private, rshared, rslave, or rprivate(default). See also mount(2). <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
. bind-nonrecursive: do not setup a recursive bind mount. By default it is recursive.
|
||||
|
||||
· from: image name for the root of the source. Defaults to **--contextdir**, mandatory if **--contextdir** was not specified.
|
||||
|
||||
· z: Set shared SELinux label on mounted destination. Use if SELinux is enabled on host machine.
|
||||
|
||||
· Z: Set private SELinux label on mounted destination. Use if SELinux is enabled on host machine.
|
||||
|
||||
Options specific to tmpfs:
|
||||
|
||||
· tmpfs-size: Size of the tmpfs mount in bytes. Unlimited by default in Linux.
|
||||
|
||||
· tmpfs-mode: File mode of the tmpfs in octal. (e.g. 700 or 0700.) Defaults to 1777 in Linux.
|
||||
|
||||
· tmpcopyup: Path that is shadowed by the tmpfs mount is recursively copied up to the tmpfs itself.
|
||||
|
||||
Options specific to secret:
|
||||
|
||||
· id: the identifier for the secret passed into the `buildah bud --secret` or `podman build --secret` command.
|
||||
|
||||
Options specific to cache:
|
||||
|
||||
· id: Distinguish this cache from other caches using this ID rather than the target mount path.
|
||||
|
||||
· mode: File mode for new cache directory in octal. Default 0755.
|
||||
|
||||
· ro, readonly: read only cache if set.
|
||||
|
||||
· uid: uid for cache directory.
|
||||
|
||||
· gid: gid for cache directory.
|
||||
|
||||
· from: stage name for the root of the source. Defaults to host cache directory.
|
||||
|
||||
· sharing: Whether other users of this cache need to wait for this command to complete (`sharing=locked`) or not (`sharing=shared`, which is the default).
|
||||
|
||||
· z: Set shared SELinux label on mounted destination. Enabled by default if SELinux is enabled on the host machine.
|
||||
|
||||
· Z: Set private SELinux label on mounted destination. Use if SELinux is enabled on host machine.
|
||||
|
||||
**--network**, **--net**=*mode*
|
||||
|
||||
Sets the configuration for the network namespace for the container.
|
||||
|
||||
Valid _mode_ values are:
|
||||
|
||||
- **none**: no networking. Invalid if using **--dns**, **--dns-opt**, or **--dns-search**;
|
||||
- **host**: use the host network stack. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure;
|
||||
- **ns:**_path_: path to a network namespace to join;
|
||||
- **private**: create a new namespace for the container (default)
|
||||
- **\<network name|ID\>**: Join the network with the given name or ID, e.g. use `--network mynet` to join the network with the name mynet. Only supported for rootful users.
|
||||
- **slirp4netns[:OPTIONS,...]**: use **slirp4netns**(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options, they can also be set with `network_cmd_options` in containers.conf:
|
||||
- **allow_host_loopback=true|false**: Allow slirp4netns to reach the host loopback IP (default is 10.0.2.2 or the second IP from slirp4netns cidr subnet when changed, see the cidr option below). The default is false.
|
||||
- **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520`).
|
||||
- **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24`).
|
||||
- **enable_ipv6=true|false**: Enable IPv6. Default is true. (Required for `outbound_addr6`).
|
||||
- **outbound_addr=INTERFACE**: Specify the outbound interface slirp binds to (ipv4 traffic only).
|
||||
- **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp binds to.
|
||||
- **outbound_addr6=INTERFACE**: Specify the outbound interface slirp binds to (ipv6 traffic only).
|
||||
- **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp binds to.
|
||||
- **pasta[:OPTIONS,...]**: use **pasta**(1) to create a user-mode networking
|
||||
stack. \
|
||||
This is only supported in rootless mode. \
|
||||
By default, IPv4 and IPv6 addresses and routes, as well as the pod interface
|
||||
name, are copied from the host. If port forwarding isn't configured, ports
|
||||
are forwarded dynamically as services are bound on either side (init
|
||||
namespace or container namespace). Port forwarding preserves the original
|
||||
source IP address. Options described in pasta(1) can be specified as
|
||||
comma-separated arguments. \
|
||||
In terms of pasta(1) options, **--config-net** is given by default, in
|
||||
order to configure networking when the container is started, and
|
||||
**--no-map-gw** is also assumed by default, to avoid direct access from
|
||||
container to host using the gateway address. The latter can be overridden
|
||||
by passing **--map-gw** in the pasta-specific options (despite not being an
|
||||
actual pasta(1) option). \
|
||||
Also, **-t none** and **-u none** are passed to disable
|
||||
automatic port forwarding based on bound ports. Similarly, **-T none** and
|
||||
**-U none** are given to disable the same functionality from container to
|
||||
host. \
|
||||
Some examples:
|
||||
- **pasta:--map-gw**: Allow the container to directly reach the host using the
|
||||
gateway address.
|
||||
- **pasta:--mtu,1500**: Specify a 1500 bytes MTU for the _tap_ interface in
|
||||
the container.
|
||||
- **pasta:--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,-m,1500,--no-ndp,--no-dhcpv6,--no-dhcp**,
|
||||
equivalent to default slirp4netns(1) options: disable IPv6, assign
|
||||
`10.0.2.0/24` to the `tap0` interface in the container, with gateway
|
||||
`10.0.2.3`, enable DNS forwarder reachable at `10.0.2.3`, set MTU to 1500
|
||||
bytes, disable NDP, DHCPv6 and DHCP support.
|
||||
- **pasta:-I,tap0,--ipv4-only,-a,10.0.2.0,-n,24,-g,10.0.2.2,--dns-forward,10.0.2.3,--no-ndp,--no-dhcpv6,--no-dhcp**,
|
||||
equivalent to default slirp4netns(1) options with Podman overrides: same as
|
||||
above, but leave the MTU to 65520 bytes
|
||||
- **pasta:-t,auto,-u,auto,-T,auto,-U,auto**: enable automatic port forwarding
|
||||
based on observed bound ports from both host and container sides
|
||||
- **pasta:-T,5201**: enable forwarding of TCP port 5201 from container to
|
||||
host, using the loopback interface instead of the tap interface for improved
|
||||
performance
|
||||
|
||||
**--no-hostname**
|
||||
|
||||
Do not create the _/etc/hostname_ file in the container for RUN instructions.
|
||||
|
||||
By default, Buildah manages the _/etc/hostname_ file, adding the container's own hostname. When the **--no-hostname** option is set, the image's _/etc/hostname_ will be preserved unmodified if it exists.
|
||||
|
||||
**--no-hosts**
|
||||
|
||||
Do not create the _/etc/hosts_ file in the container for RUN instructions.
|
||||
|
||||
By default, Buildah manages _/etc/hosts_, adding the container's own IP address.
|
||||
**--no-hosts** disables this, and the image's _/etc/hosts_ will be preserved unmodified.
|
||||
|
||||
**--no-pivot**
|
||||
|
||||
Do not use pivot root to jail process inside rootfs. This should be used
|
||||
whenever the rootfs is on top of a ramdisk.
|
||||
|
||||
Note: You can make this option the default by setting the BUILDAH\_NOPIVOT
|
||||
environment variable. `export BUILDAH_NOPIVOT=true`
|
||||
|
||||
**--pid** *how*
|
||||
|
||||
Sets the configuration for the PID namespace for the container.
|
||||
The configured value can be "" (the empty string) or "private" to indicate
|
||||
that a new PID namespace should be created, or it can be "host" to indicate
|
||||
that the PID namespace in which `buildah` itself is being run should be reused,
|
||||
or it can be the path to a PID namespace which is already in use by another
|
||||
process.
|
||||
|
||||
**--runtime** *path*
|
||||
|
||||
The *path* to an alternate OCI-compatible runtime. Default is `runc`, or `crun` when machine is configured to use cgroups V2.
|
||||
|
||||
Note: You can also override the default runtime by setting the BUILDAH\_RUNTIME
|
||||
environment variable. `export BUILDAH_RUNTIME=/usr/bin/crun`
|
||||
|
||||
**--runtime-flag** *flag*
|
||||
|
||||
Adds global flags for the container runtime. To list the supported flags, please
|
||||
consult the manpages of the selected container runtime.
|
||||
Note: Do not pass the leading `--` to the flag. To pass the runc flag `--log-format json`
|
||||
to buildah run, the option given would be `--runtime-flag log-format=json`.
|
||||
|
||||
**--tty**, **--terminal**, **-t**
|
||||
|
||||
By default a pseudo-TTY is allocated only when buildah's standard input is
|
||||
attached to a pseudo-TTY. Setting the `--tty` option to `true` will cause a
|
||||
pseudo-TTY to be allocated inside the container connecting the user's "terminal"
|
||||
with the stdin and stdout stream of the container. Setting the `--tty` option to
|
||||
`false` will prevent the pseudo-TTY from being allocated.
|
||||
|
||||
**--user** *user*[:*group*]
|
||||
|
||||
Set the *user* to be used for running the command in the container.
|
||||
The user can be specified as a user name
|
||||
or UID, optionally followed by a group name or GID, separated by a colon (':').
|
||||
If names are used, the container should include entries for those names in its
|
||||
*/etc/passwd* and */etc/group* files.
|
||||
|
||||
**--uts** *how*
|
||||
|
||||
Sets the configuration for the UTS namespace for the container.
|
||||
The configured value can be "" (the empty string) or "private" to indicate
|
||||
that a new UTS namespace should be created, or it can be "host" to indicate
|
||||
that the UTS namespace in which `buildah` itself is being run should be reused,
|
||||
or it can be the path to a UTS namespace which is already in use by another
|
||||
process.
|
||||
|
||||
**--volume**, **-v** *source*:*destination*:*options*
|
||||
|
||||
Create a bind mount. If you specify, ` -v /HOST-DIR:/CONTAINER-DIR`, Buildah
|
||||
bind mounts `/HOST-DIR` in the host to `/CONTAINER-DIR` in the Buildah
|
||||
container. The `OPTIONS` are a comma delimited list and can be:
|
||||
|
||||
* [rw|ro]
|
||||
* [U]
|
||||
* [z|Z]
|
||||
* [`[r]shared`|`[r]slave`|`[r]private`] <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
The `CONTAINER-DIR` must be an absolute path such as `/src/docs`. The `HOST-DIR`
|
||||
must be an absolute path as well. Buildah bind-mounts the `HOST-DIR` to the
|
||||
path you specify. For example, if you supply `/foo` as the host path,
|
||||
Buildah copies the contents of `/foo` to the container filesystem on the host
|
||||
and bind mounts that into the container.
|
||||
|
||||
You can specify multiple **-v** options to mount one or more mounts to a
|
||||
container.
|
||||
|
||||
`Write Protected Volume Mounts`
|
||||
|
||||
You can add the `:ro` or `:rw` suffix to a volume to mount it read-only or
|
||||
read-write mode, respectively. By default, the volumes are mounted read-write.
|
||||
See examples.
|
||||
|
||||
`Chowning Volume Mounts`
|
||||
|
||||
By default, Buildah does not change the owner and group of source volume directories mounted into containers. If a container is created in a new user namespace, the UID and GID in the container may correspond to another UID and GID on the host.
|
||||
|
||||
The `:U` suffix tells Buildah to use the correct host UID and GID based on the UID and GID within the container, to change the owner and group of the source volume.
|
||||
|
||||
`Labeling Volume Mounts`
|
||||
|
||||
Labeling systems like SELinux require that proper labels are placed on volume
|
||||
content mounted into a container. Without a label, the security system might
|
||||
prevent the processes running inside the container from using the content. By
|
||||
default, Buildah does not change the labels set by the OS.
|
||||
|
||||
To change a label in the container context, you can add either of two suffixes
|
||||
`:z` or `:Z` to the volume mount. These suffixes tell Buildah to relabel file
|
||||
objects on the shared volumes. The `z` option tells Buildah that two containers
|
||||
share the volume content. As a result, Buildah labels the content with a shared
|
||||
content label. Shared volume labels allow all containers to read/write content.
|
||||
The `Z` option tells Buildah to label the content with a private unshared label.
|
||||
Only the current container can use a private volume.
|
||||
|
||||
By default bind mounted volumes are `private`. That means any mounts done
|
||||
inside container will not be visible on the host and vice versa. This behavior can
|
||||
be changed by specifying a volume mount propagation property.
|
||||
|
||||
When the mount propagation policy is set to `shared`, any mounts completed inside
|
||||
the container on that volume will be visible to both the host and container. When
|
||||
the mount propagation policy is set to `slave`, one way mount propagation is enabled
|
||||
and any mounts completed on the host for that volume will be visible only inside of the container.
|
||||
To control the mount propagation property of the volume use the `:[r]shared`,
|
||||
`:[r]slave` or `:[r]private` propagation flag. The propagation property can
|
||||
be specified only for bind mounted volumes and not for internal volumes or
|
||||
named volumes. For mount propagation to work on the source mount point (the mount point
|
||||
where source dir is mounted on) it has to have the right propagation properties. For
|
||||
shared volumes, the source mount point has to be shared. And for slave volumes,
|
||||
the source mount has to be either shared or slave. <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
Use `df <source-dir>` to determine the source mount and then use
|
||||
`findmnt -o TARGET,PROPAGATION <source-mount-dir>` to determine propagation
|
||||
properties of source mount, if `findmnt` utility is not available, the source mount point
|
||||
can be determined by looking at the mount entry in `/proc/self/mountinfo`. Look
|
||||
at `optional fields` and see if any propagation properties are specified.
|
||||
`shared:X` means the mount is `shared`, `master:X` means the mount is `slave` and if
|
||||
nothing is there that means the mount is `private`. <sup>[[1]](#Footnote1)</sup>
|
||||
|
||||
To change propagation properties of a mount point use the `mount` command. For
|
||||
example, to bind mount the source directory `/foo` do
|
||||
`mount --bind /foo /foo` and `mount --make-private --make-shared /foo`. This
|
||||
will convert /foo into a `shared` mount point. The propagation properties of the source
|
||||
mount can be changed directly. For instance if `/` is the source mount for
|
||||
`/foo`, then use `mount --make-shared /` to convert `/` into a `shared` mount.
|
||||
|
||||
**--workingdir** *directory*
|
||||
|
||||
Temporarily set the working *directory* for the running process. Unlike
|
||||
`buildah config --workingdir`, the workingdir will not persist to later
|
||||
calls to `buildah run` or the built image.
|
||||
|
||||
|
||||
NOTE: End parsing of options with the `--` option, so that other
|
||||
options can be passed to the command inside of the container.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah run containerID -- ps -auxw
|
||||
|
||||
buildah run --hostname myhost containerID -- ps -auxw
|
||||
|
||||
buildah run containerID -- sh -c 'echo $PATH'
|
||||
|
||||
buildah run --runtime-flag log-format=json containerID /bin/bash
|
||||
|
||||
buildah run --runtime-flag debug containerID /bin/bash
|
||||
|
||||
buildah run --tty containerID /bin/bash
|
||||
|
||||
buildah run --tty=false containerID ls /
|
||||
|
||||
buildah run --volume /path/on/host:/path/in/container:ro,z containerID sh
|
||||
|
||||
buildah run -v /path/on/host:/path/in/container:z,U containerID sh
|
||||
|
||||
buildah run --mount type=bind,src=/tmp/on:host,dst=/in:container,ro containerID sh
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-from(1), buildah-config(1), namespaces(7), pid\_namespaces(7), crun(1), runc(8), containers.conf(5)
|
||||
|
||||
## FOOTNOTES
|
||||
<a name="Footnote1">1</a>: The Buildah project is committed to inclusivity, a core value of open source. The `master` and `slave` mount propagation terminology used here is problematic and divisive, and should be changed. However, these terms are currently used within the Linux kernel and must be used as-is at this time. When the kernel maintainers rectify this usage, Buildah will follow suit immediately.
|
@@ -0,0 +1,21 @@
|
||||
# buildah-source-add "1" "March 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-source\-add - Add a source artifact to a source image
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah source add** [*options*] *path* *artifact*
|
||||
|
||||
## DESCRIPTION
|
||||
Add add a source artifact to a source image. The artifact will be added as a
|
||||
gzip-compressed tar ball. Add attempts to auto-tar and auto-compress only if
|
||||
necessary.
|
||||
|
||||
Note that the buildah-source command and all its subcommands are experimental
|
||||
and may be subject to future changes
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--annotation** *key=value*
|
||||
|
||||
Add an annotation to the layer descriptor in the source-image manifest. The input format is `key=value`.
|
@@ -0,0 +1,24 @@
|
||||
# buildah-source-create "1" "March 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-source\-create - Create and initialize a source image
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah source create** [*options*] *path*
|
||||
|
||||
## DESCRIPTION
|
||||
Create and initialize a source image. A source image is an OCI artifact; an
|
||||
OCI image with a custom config media type.
|
||||
|
||||
Note that the buildah-source command and all its subcommands are experimental
|
||||
and may be subject to future changes
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--author** *author*
|
||||
|
||||
Set the author of the source image mentioned in the config. By default, no author is set.
|
||||
|
||||
**--time-stamp** *bool-value*
|
||||
|
||||
Set the created time stamp in the image config. By default, the time stamp is set.
|
@@ -0,0 +1,32 @@
|
||||
# buildah-source-pull "1" "March 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-source\-pull - Pull a source image from a registry to a specified path
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah source pull** [*options*] *registry* *path*
|
||||
|
||||
## DESCRIPTION
|
||||
Pull a source image from a registry to a specified path. The pull operation
|
||||
will fail if the image does not comply with a source-image OCI artifact.
|
||||
|
||||
Note that the buildah-source command and all its subcommands are experimental
|
||||
and may be subject to future changes.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Suppress the progress output when pulling a source image.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
@@ -0,0 +1,35 @@
|
||||
# buildah-source-push "1" "March 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-source\-push - Push a source image from a specified path to a registry.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah source push** [*options*] *path* *registry*
|
||||
|
||||
## DESCRIPTION
|
||||
Push a source image from a specified path to a registry.
|
||||
|
||||
Note that the buildah-source command and all its subcommands are experimental
|
||||
and may be subject to future changes.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--creds** *creds*
|
||||
|
||||
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.
|
||||
|
||||
**--digestfile** *digestfile*
|
||||
|
||||
After copying the image, write the digest of the resulting image to the file.
|
||||
|
||||
**--quiet**, **-q**
|
||||
|
||||
Suppress the progress output when pushing a source image.
|
||||
|
||||
**--tls-verify** *bool-value*
|
||||
|
||||
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.
|
@@ -0,0 +1,31 @@
|
||||
# buildah-source "1" "March 2021" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-source - Create, push, pull and manage source images and associated source artifacts
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah source** *subcommand*
|
||||
|
||||
## DESCRIPTION
|
||||
Create, push, pull and manage source images and associated source artifacts. A
|
||||
source image contains all source artifacts an ordinary OCI image has been built
|
||||
with. Those artifacts can be any kind of source artifact, such as source RPMs,
|
||||
an entire source tree or text files.
|
||||
|
||||
Note that the buildah-source command and all its subcommands are experimental
|
||||
and may be subject to future changes.
|
||||
|
||||
## COMMANDS
|
||||
|
||||
| Command | Man Page | Description |
|
||||
| -------- | ------------------------------------------------------ | ---------------------------------------------------------- |
|
||||
| add | [buildah-source-add(1)](buildah-source-add.1.md) | Add a source artifact to a source image. |
|
||||
| create | [buildah-source-create(1)](buildah-source-create.1.md) | Create and initialize a source image. |
|
||||
| pull | [buildah-source-pull(1)](buildah-source-pull.1.md) | Pull a source image from a registry to a specified path. |
|
||||
| push | [buildah-source-push(1)](buildah-source-push.1.md) | Push a source image from a specified path to a registry. |
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
||||
|
||||
## HISTORY
|
||||
June 2021, Originally compiled by Valentin Rothberg <vrothber@redhat.com>
|
@@ -0,0 +1,19 @@
|
||||
# buildah-tag "1" "May 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-tag - Add additional names to local images.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah tag** *name* *new-name* ...
|
||||
|
||||
## DESCRIPTION
|
||||
Adds additional names to locally-stored images.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah tag imageName firstNewName
|
||||
|
||||
buildah tag imageName firstNewName SecondNewName
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
@@ -0,0 +1,27 @@
|
||||
# buildah-umount "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-umount - Unmount the root file system on the specified working containers.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah umount** [*options*] [*container* ...]
|
||||
|
||||
## DESCRIPTION
|
||||
Unmounts the root file system on the specified working containers.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--all**, **-a**
|
||||
|
||||
All of the currently mounted containers will be unmounted.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah umount containerID
|
||||
|
||||
buildah umount containerID1 containerID2 containerID3
|
||||
|
||||
buildah umount --all
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-umount(1)
|
@@ -0,0 +1,63 @@
|
||||
# buildah-unshare "1" "June 2018" "buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-unshare - Run a command inside of a modified user namespace.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah unshare** [*options*] [**--**] [*command*]
|
||||
|
||||
## DESCRIPTION
|
||||
Launches a process (by default, *$SHELL*) in a new user namespace. The user
|
||||
namespace is configured so that the invoking user's UID and primary GID appear
|
||||
to be UID 0 and GID 0, respectively. Any ranges which match that user and
|
||||
group in /etc/subuid and /etc/subgid are also mapped in as themselves with the
|
||||
help of the *newuidmap(1)* and *newgidmap(1)* helpers.
|
||||
|
||||
buildah unshare is useful for troubleshooting unprivileged operations and for
|
||||
manually clearing storage and other data related to images and containers.
|
||||
|
||||
It is also useful if you want to use the `buildah mount` command. If an unprivileged user wants to mount and work with a container, then they need to execute
|
||||
buildah unshare. Executing `buildah mount` fails for unprivileged users unless the user is running inside a `buildah unshare` session.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--mount**, **-m** [*VARIABLE=]containerNameOrID*
|
||||
|
||||
Mount the *containerNameOrID* container while running *command*, and set the
|
||||
environment variable *VARIABLE* to the path of the mountpoint. If *VARIABLE*
|
||||
is not specified, it defaults to *containerNameOrID*, which may not be a valid
|
||||
name for an environment variable.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah unshare id
|
||||
|
||||
buildah unshare pwd
|
||||
|
||||
buildah unshare cat /proc/self/uid\_map /proc/self/gid\_map
|
||||
|
||||
buildah unshare rm -fr $HOME/.local/share/containers/storage /run/user/\`id -u\`/run
|
||||
|
||||
buildah unshare --mount containerID sh -c 'cat ${containerID}/etc/os-release'
|
||||
|
||||
If you want to use buildah with a mount command then you can create a script that looks something like:
|
||||
|
||||
```
|
||||
cat buildah-script.sh << _EOF
|
||||
#!/bin/sh
|
||||
ctr=$(buildah from scratch)
|
||||
mnt=$(buildah mount $ctr)
|
||||
dnf -y install --installroot=$mnt PACKAGES
|
||||
dnf -y clean all --installroot=$mnt
|
||||
buildah config --entrypoint="/bin/PACKAGE" --env "FOO=BAR" $ctr
|
||||
buildah commit $ctr imagename
|
||||
buildah unmount $ctr
|
||||
_EOF
|
||||
```
|
||||
Then execute it with:
|
||||
```
|
||||
buildah unshare buildah-script.sh
|
||||
```
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1), buildah-mount(1), namespaces(7), newuidmap(1), newgidmap(1), user\_namespaces(7)
|
@@ -0,0 +1,31 @@
|
||||
# buildah-version "1" "June 2017" "Buildah"
|
||||
|
||||
## NAME
|
||||
buildah\-version - Display the Buildah Version Information.
|
||||
|
||||
## SYNOPSIS
|
||||
**buildah version** [*options*]
|
||||
|
||||
## DESCRIPTION
|
||||
Shows the following information: Version, Go Version, Image Spec, Runtime Spec, CNI Spec, libcni Version, Git Commit, Build Time, OS, and Architecture.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--help, -h**
|
||||
|
||||
Print usage statement
|
||||
|
||||
**--json**
|
||||
|
||||
Output in JSON format.
|
||||
|
||||
## EXAMPLE
|
||||
|
||||
buildah version
|
||||
|
||||
buildah version --help
|
||||
|
||||
buildah version -h
|
||||
|
||||
## SEE ALSO
|
||||
buildah(1)
|
207
packages/system/virt/src/buildah/buildahdocs/buildah.1.md
Normal file
207
packages/system/virt/src/buildah/buildahdocs/buildah.1.md
Normal file
@@ -0,0 +1,207 @@
|
||||
# buildah "1" "March 2017" "buildah"
|
||||
|
||||
## NAME
|
||||
Buildah - A command line tool that facilitates building OCI container images.
|
||||
|
||||
## SYNOPSIS
|
||||
buildah [OPTIONS] COMMAND [ARG...]
|
||||
|
||||
|
||||
## DESCRIPTION
|
||||
The Buildah package provides a command line tool which can be used to:
|
||||
|
||||
* Create a working container, either from scratch or using an image as a starting point.
|
||||
* Mount a working container's root filesystem for manipulation.
|
||||
* Unmount a working container's root filesystem.
|
||||
* Use the updated contents of a container's root filesystem as a filesystem layer to create a new image.
|
||||
* Delete a working container or an image.
|
||||
* Rename a local container.
|
||||
|
||||
|
||||
## OPTIONS
|
||||
|
||||
**--cgroup-manager**=*manager*
|
||||
|
||||
The CGroup manager to use for container cgroups. Supported values are cgroupfs or systemd. Default is systemd unless overridden in the containers.conf file.
|
||||
|
||||
Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type.
|
||||
Note: CGroup manager is not supported in rootless mode when using CGroups Version V1.
|
||||
|
||||
**--log-level** **value**
|
||||
|
||||
The log level to be used. Either "trace", "debug", "info", "warn", "error", "fatal", or "panic", defaulting to "warn".
|
||||
|
||||
**--help, -h**
|
||||
|
||||
Show help
|
||||
|
||||
**--registries-conf** *path*
|
||||
|
||||
Pathname of the configuration file which specifies which container registries should be
|
||||
consulted when completing image names which do not include a registry or domain
|
||||
portion. It is not recommended that this option be used, as the default
|
||||
behavior of using the system-wide configuration
|
||||
(*/etc/containers/registries.conf*) is most often preferred.
|
||||
|
||||
**--registries-conf-dir** *path*
|
||||
|
||||
Pathname of the directory which contains configuration snippets which specify
|
||||
registries which should be consulted when completing image names which do not
|
||||
include a registry or domain portion. It is not recommended that this option
|
||||
be used, as the default behavior of using the system-wide configuration
|
||||
(*/etc/containers/registries.d*) is most often preferred.
|
||||
|
||||
**--root** **value**
|
||||
|
||||
Storage root dir (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users)
|
||||
Default root dir is configured in /etc/containers/storage.conf
|
||||
|
||||
**--runroot** **value**
|
||||
|
||||
Storage state dir (default: "/run/containers/storage" for UID 0, "/run/user/$UID" for other users)
|
||||
Default state dir is configured in /etc/containers/storage.conf
|
||||
|
||||
**--short-name-alias-conf** *path*
|
||||
|
||||
Pathname of the file which contains cached mappings between short image names
|
||||
and their corresponding fully-qualified names. It is used for mapping from
|
||||
names of images specified using short names like "ubi8" which don't
|
||||
include a registry component and a corresponding fully-specified name which
|
||||
includes a registry and any other components, such as
|
||||
"registry.access.redhat.com/ubi8". It is not recommended that this option be
|
||||
used, as the default behavior of using the system-wide cache
|
||||
(*/var/cache/containers/short-name-aliases.conf*) or per-user cache
|
||||
(*$HOME/.cache/containers/short-name-aliases.conf*) to supplement system-wide
|
||||
defaults is most often preferred.
|
||||
|
||||
**--storage-driver** **value**
|
||||
|
||||
Storage driver. The default storage driver for UID 0 is configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode), and is *vfs* for other users. The `STORAGE_DRIVER` environment variable overrides the default. The --storage-driver specified driver overrides all.
|
||||
|
||||
Examples: "overlay", "vfs"
|
||||
|
||||
Overriding this option will cause the *storage-opt* settings in /etc/containers/storage.conf to be ignored. The user must
|
||||
specify additional options via the `--storage-opt` flag.
|
||||
|
||||
**--storage-opt** **value**
|
||||
|
||||
Storage driver option, Default storage driver options are configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode). The `STORAGE_OPTS` environment variable overrides the default. The --storage-opt specified options overrides all.
|
||||
|
||||
**--userns-gid-map** *mapping*
|
||||
|
||||
Directly specifies a GID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the working container's contents.
|
||||
Commands run when handling `RUN` instructions will default to being run in
|
||||
their own user namespaces, configured using the UID and GID maps.
|
||||
|
||||
Entries in this map take the form of one or more colon-separated triples of a starting
|
||||
in-container GID, a corresponding starting host-level GID, and the number of
|
||||
consecutive IDs which the map entry represents.
|
||||
|
||||
This option overrides the *remap-gids* setting in the *options* section of
|
||||
/etc/containers/storage.conf.
|
||||
|
||||
If this option is not specified, but a global --userns-gid-map setting is
|
||||
supplied, settings from the global option will be used.
|
||||
|
||||
If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-gid-map
|
||||
are specified, but --userns-uid-map is specified, the GID map will be set to
|
||||
use the same numeric values as the UID map.
|
||||
|
||||
**NOTE:** When this option is specified by a rootless user, the specified mappings are relative to the rootless usernamespace in the container, rather than being relative to the host as it would be when run rootful.
|
||||
|
||||
**--userns-uid-map** *mapping*
|
||||
|
||||
Directly specifies a UID mapping which should be used to set ownership, at the
|
||||
filesystem level, on the working container's contents.
|
||||
Commands run when handling `RUN` instructions will default to being run in
|
||||
their own user namespaces, configured using the UID and GID maps.
|
||||
|
||||
Entries in this map take the form of one or more colon-separated triples of a starting
|
||||
in-container UID, a corresponding starting host-level UID, and the number of
|
||||
consecutive IDs which the map entry represents.
|
||||
|
||||
This option overrides the *remap-uids* setting in the *options* section of
|
||||
/etc/containers/storage.conf.
|
||||
|
||||
If this option is not specified, but a global --userns-uid-map setting is
|
||||
supplied, settings from the global option will be used.
|
||||
|
||||
If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-uid-map
|
||||
are specified, but --userns-gid-map is specified, the UID map will be set to
|
||||
use the same numeric values as the GID map.
|
||||
|
||||
**NOTE:** When this option is specified by a rootless user, the specified mappings are relative to the rootless usernamespace in the container, rather than being relative to the host as it would be when run rootful.
|
||||
|
||||
**--version**, **-v**
|
||||
|
||||
Print the version
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Buildah can set up environment variables from the env entry in the [engine] table in the containers.conf(5). These variables can be overridden by passing environment variables before the `buildah` commands.
|
||||
|
||||
## COMMANDS
|
||||
|
||||
| Command | Man Page | Description |
|
||||
| ---------- | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
|
||||
| add | [buildah-add(1)](buildah-add.1.md) | Add the contents of a file, URL, or a directory to the container. |
|
||||
| build | [buildah-build(1)](buildah-build.1.md) | Builds an OCI image using instructions in one or more Containerfiles. |
|
||||
| commit | [buildah-commit(1)](buildah-commit.1.md) | Create an image from a working container. |
|
||||
| config | [buildah-config(1)](buildah-config.1.md) | Update image configuration settings. |
|
||||
| containers | [buildah-containers(1)](buildah-containers.1.md) | List the working containers and their base images. |
|
||||
| copy | [buildah-copy(1)](buildah-copy.1.md) | Copies the contents of a file, URL, or directory into a container's working directory. |
|
||||
| from | [buildah-from(1)](buildah-from.1.md) | Creates a new working container, either from scratch or using a specified image as a starting point. |
|
||||
| images | [buildah-images(1)](buildah-images.1.md) | List images in local storage. |
|
||||
| info | [buildah-info(1)](buildah-info.1.md) | Display Buildah system information. |
|
||||
| inspect | [buildah-inspect(1)](buildah-inspect.1.md) | Inspects the configuration of a container or image |
|
||||
| login | [buildah-login(1)](buildah-login.1.md) | Login to a container registry. |
|
||||
| logout | [buildah-logout(1)](buildah-logout.1.md) | Logout of a container registry |
|
||||
| manifest | [buildah-manifest(1)](buildah-manifest.1.md) | Create and manipulate manifest lists and image indexes. |
|
||||
| mkcw | [buildah-mkcw(1)](buildah-mkcw.1.md) | Convert a conventional container image into a confidential workload image.
|
||||
| mount | [buildah-mount(1)](buildah-mount.1.md) | Mount the working container's root filesystem. |
|
||||
| prune | [buildah-prune(1)](buildah-prune.1.md) | Cleanup intermediate images as well as build and mount cache. |
|
||||
| pull | [buildah-pull(1)](buildah-pull.1.md) | Pull an image from the specified location. |
|
||||
| push | [buildah-push(1)](buildah-push.1.md) | Push an image from local storage to elsewhere. |
|
||||
| rename | [buildah-rename(1)](buildah-rename.1.md) | Rename a local container. |
|
||||
| rm | [buildah-rm(1)](buildah-rm.1.md) | Removes one or more working containers. |
|
||||
| rmi | [buildah-rmi(1)](buildah-rmi.1.md) | Removes one or more images. |
|
||||
| run | [buildah-run(1)](buildah-run.1.md) | Run a command inside of the container. |
|
||||
| source | [buildah-source(1)](buildah-source.1.md) | Create, push, pull and manage source images and associated source artifacts. |
|
||||
| tag | [buildah-tag(1)](buildah-tag.1.md) | Add an additional name to a local image. |
|
||||
| umount | [buildah-umount(1)](buildah-umount.1.md) | Unmount a working container's root file system. |
|
||||
| unshare | [buildah-unshare(1)](buildah-unshare.1.md) | Launch a command in a user namespace with modified ID mappings. |
|
||||
| version | [buildah-version(1)](buildah-version.1.md) | Display the Buildah Version Information |
|
||||
|
||||
|
||||
## Files
|
||||
|
||||
**storage.conf** (`/etc/containers/storage.conf`)
|
||||
|
||||
storage.conf is the storage configuration file for all tools using containers/storage
|
||||
|
||||
The storage configuration file specifies all of the available container storage options for tools using shared container storage.
|
||||
|
||||
**mounts.conf** (`/usr/share/containers/mounts.conf` and optionally `/etc/containers/mounts.conf`)
|
||||
|
||||
The mounts.conf files specify volume mount files or directories that are automatically mounted inside containers when executing the `buildah run` or `buildah build` commands. Container processes can then use this content. The volume mount content does not get committed to the final image.
|
||||
|
||||
Usually these directories are used for passing secrets or credentials required by the package software to access remote package repositories.
|
||||
|
||||
For example, a mounts.conf with the line "`/usr/share/rhel/secrets:/run/secrets`", the content of `/usr/share/rhel/secrets` directory is mounted on `/run/secrets` inside the container. This mountpoint allows Red Hat Enterprise Linux subscriptions from the host to be used within the container. It is also possible to omit the destination if it's equal to the source path. For example, specifying `/var/lib/secrets` will mount the directory into the same container destination path `/var/lib/secrets`.
|
||||
|
||||
Note this is not a volume mount. The content of the volumes is copied into container storage, not bind mounted directly from the host.
|
||||
|
||||
**registries.conf** (`/etc/containers/registries.conf`)
|
||||
|
||||
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.
|
||||
|
||||
**registries.d** (`/etc/containers/registries.d`)
|
||||
|
||||
Directory which contains configuration snippets which specify registries which should be consulted when completing image names which do not include a registry or domain portion.
|
||||
|
||||
## SEE ALSO
|
||||
containers.conf(5), containers-mounts.conf(5), newuidmap(1), newgidmap(1), containers-registries.conf(5), containers-storage.conf(5)
|
||||
|
||||
## HISTORY
|
||||
December 2017, Originally compiled by Tom Sweeney <tsweeney@redhat.com>
|
919
packages/system/virt/src/buildah/builder.rs
Normal file
919
packages/system/virt/src/buildah/builder.rs
Normal file
@@ -0,0 +1,919 @@
|
||||
use crate::buildah::{
|
||||
execute_buildah_command, set_thread_local_debug, thread_local_debug, BuildahError, Image,
|
||||
};
|
||||
use sal_process::CommandResult;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Builder struct for buildah operations
|
||||
#[derive(Clone)]
|
||||
pub struct Builder {
|
||||
/// Name of the container
|
||||
name: String,
|
||||
/// Container ID
|
||||
container_id: Option<String>,
|
||||
/// Base image
|
||||
image: String,
|
||||
/// Debug mode
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
/// Create a new builder with a container from the specified image
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `name` - Name for the container
|
||||
/// * `image` - Image to create the container from
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<Self, BuildahError>` - Builder instance or error
|
||||
pub fn new(name: &str, image: &str) -> Result<Self, BuildahError> {
|
||||
// Try to create a new container
|
||||
let result = execute_buildah_command(&["from", "--name", name, image]);
|
||||
|
||||
match result {
|
||||
Ok(success_result) => {
|
||||
// Container created successfully
|
||||
let container_id = success_result.stdout.trim().to_string();
|
||||
|
||||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
container_id: Some(container_id),
|
||||
image: image.to_string(),
|
||||
debug: false,
|
||||
})
|
||||
}
|
||||
Err(BuildahError::CommandFailed(error_msg)) => {
|
||||
// Check if the error is because the container already exists
|
||||
if error_msg.contains("that name is already in use") {
|
||||
// Extract the container ID from the error message
|
||||
// Error format: "the container name "name" is already in use by container_id. You have to remove that container to be able to reuse that name: that name is already in use"
|
||||
let container_id = error_msg
|
||||
.split("already in use by ")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('.').next())
|
||||
.unwrap_or("")
|
||||
.trim()
|
||||
.to_string();
|
||||
|
||||
if !container_id.is_empty() {
|
||||
// Container already exists, continue with it
|
||||
Ok(Self {
|
||||
name: name.to_string(),
|
||||
container_id: Some(container_id),
|
||||
image: image.to_string(),
|
||||
debug: false,
|
||||
})
|
||||
} else {
|
||||
// Couldn't extract container ID
|
||||
Err(BuildahError::Other(
|
||||
"Failed to extract container ID from error message".to_string(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
// Other command failure
|
||||
Err(BuildahError::CommandFailed(error_msg))
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
// Other error
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the container ID
|
||||
pub fn container_id(&self) -> Option<&String> {
|
||||
self.container_id.as_ref()
|
||||
}
|
||||
|
||||
/// Get the container name
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
/// Get the debug mode
|
||||
pub fn debug(&self) -> bool {
|
||||
self.debug
|
||||
}
|
||||
|
||||
/// Set the debug mode
|
||||
pub fn set_debug(&mut self, debug: bool) -> &mut Self {
|
||||
self.debug = debug;
|
||||
self
|
||||
}
|
||||
|
||||
/// Get the base image
|
||||
pub fn image(&self) -> &str {
|
||||
&self.image
|
||||
}
|
||||
|
||||
/// Run a command in the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `command` - The command to run
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn run(&self, command: &str) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["run", container_id, "sh", "-c", command]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Run a command in the container with specified isolation
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `command` - The command to run
|
||||
/// * `isolation` - Isolation method (e.g., "chroot", "rootless", "oci")
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn run_with_isolation(
|
||||
&self,
|
||||
command: &str,
|
||||
isolation: &str,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&[
|
||||
"run",
|
||||
"--isolation",
|
||||
isolation,
|
||||
container_id,
|
||||
"sh",
|
||||
"-c",
|
||||
command,
|
||||
]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy files into the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `source` - Source path
|
||||
/// * `dest` - Destination path in the container
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn copy(&self, source: &str, dest: &str) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["copy", container_id, source, dest]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Add files into the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `source` - Source path
|
||||
/// * `dest` - Destination path in the container
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn add(&self, source: &str, dest: &str) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["add", container_id, source, dest]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Commit the container to an image
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image_name` - Name for the new image
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn commit(&self, image_name: &str) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["commit", container_id, image_name]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove the container
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn remove(&self) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["rm", container_id]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset the builder by removing the container and clearing the container_id
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<(), BuildahError>` - Success or error
|
||||
pub fn reset(&mut self) -> Result<(), BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Try to remove the container
|
||||
let result = execute_buildah_command(&["rm", container_id]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
// Clear the container_id regardless of whether the removal succeeded
|
||||
self.container_id = None;
|
||||
|
||||
// Return the result of the removal operation
|
||||
match result {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
} else {
|
||||
// No container to remove
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Configure container metadata
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `options` - Map of configuration options
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn config(&self, options: HashMap<String, String>) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
let mut args_owned: Vec<String> = Vec::new();
|
||||
args_owned.push("config".to_string());
|
||||
|
||||
// Process options map
|
||||
for (key, value) in options.iter() {
|
||||
let option_name = format!("--{}", key);
|
||||
args_owned.push(option_name);
|
||||
args_owned.push(value.clone());
|
||||
}
|
||||
|
||||
args_owned.push(container_id.clone());
|
||||
|
||||
// Convert Vec<String> to Vec<&str> for execute_buildah_command
|
||||
let args: Vec<&str> = args_owned.iter().map(|s| s.as_str()).collect();
|
||||
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&args);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the entrypoint for the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `entrypoint` - The entrypoint command
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn set_entrypoint(&self, entrypoint: &str) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result =
|
||||
execute_buildah_command(&["config", "--entrypoint", entrypoint, container_id]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the default command for the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `cmd` - The default command
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn set_cmd(&self, cmd: &str) -> Result<CommandResult, BuildahError> {
|
||||
if let Some(container_id) = &self.container_id {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag from the Builder's debug flag
|
||||
set_thread_local_debug(self.debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["config", "--cmd", cmd, container_id]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
} else {
|
||||
Err(BuildahError::Other("No container ID available".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// List images in local storage
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<Vec<Image>, BuildahError>` - List of images or error
|
||||
pub fn images() -> Result<Vec<Image>, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
let result = execute_buildah_command(&["images", "--json"])?;
|
||||
|
||||
// Try to parse the JSON output
|
||||
match serde_json::from_str::<serde_json::Value>(&result.stdout) {
|
||||
Ok(json) => {
|
||||
if let serde_json::Value::Array(images_json) = json {
|
||||
let mut images = Vec::new();
|
||||
|
||||
for image_json in images_json {
|
||||
// Extract image ID
|
||||
let id = match image_json.get("id").and_then(|v| v.as_str()) {
|
||||
Some(id) => id.to_string(),
|
||||
None => {
|
||||
return Err(BuildahError::ConversionError(
|
||||
"Missing image ID".to_string(),
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
// Extract image names
|
||||
let names = match image_json.get("names").and_then(|v| v.as_array()) {
|
||||
Some(names_array) => {
|
||||
let mut names_vec = Vec::new();
|
||||
for name_value in names_array {
|
||||
if let Some(name_str) = name_value.as_str() {
|
||||
names_vec.push(name_str.to_string());
|
||||
}
|
||||
}
|
||||
names_vec
|
||||
}
|
||||
None => Vec::new(), // Empty vector if no names found
|
||||
};
|
||||
|
||||
// Extract image size
|
||||
let size = match image_json.get("size").and_then(|v| v.as_str()) {
|
||||
Some(size) => size.to_string(),
|
||||
None => "Unknown".to_string(), // Default value if size not found
|
||||
};
|
||||
|
||||
// Extract creation timestamp
|
||||
let created = match image_json.get("created").and_then(|v| v.as_str()) {
|
||||
Some(created) => created.to_string(),
|
||||
None => "Unknown".to_string(), // Default value if created not found
|
||||
};
|
||||
|
||||
// Create Image struct and add to vector
|
||||
images.push(Image {
|
||||
id,
|
||||
names,
|
||||
size,
|
||||
created,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(images)
|
||||
} else {
|
||||
Err(BuildahError::JsonParseError(
|
||||
"Expected JSON array".to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
Err(e) => Err(BuildahError::JsonParseError(format!(
|
||||
"Failed to parse image list JSON: {}",
|
||||
e
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove an image
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image ID or name
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_remove(image: &str) -> Result<CommandResult, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
execute_buildah_command(&["rmi", image])
|
||||
}
|
||||
|
||||
/// Remove an image with debug output
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image ID or name
|
||||
/// * `debug` - Whether to enable debug output
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_remove_with_debug(
|
||||
image: &str,
|
||||
debug: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag
|
||||
set_thread_local_debug(debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["rmi", image]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Pull an image from a registry
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image name
|
||||
/// * `tls_verify` - Whether to verify TLS
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_pull(image: &str, tls_verify: bool) -> Result<CommandResult, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
let mut args = vec!["pull"];
|
||||
|
||||
if !tls_verify {
|
||||
args.push("--tls-verify=false");
|
||||
}
|
||||
|
||||
args.push(image);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Pull an image from a registry with debug output
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image name
|
||||
/// * `tls_verify` - Whether to verify TLS
|
||||
/// * `debug` - Whether to enable debug output
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_pull_with_debug(
|
||||
image: &str,
|
||||
tls_verify: bool,
|
||||
debug: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag
|
||||
set_thread_local_debug(debug);
|
||||
|
||||
let mut args = vec!["pull"];
|
||||
|
||||
if !tls_verify {
|
||||
args.push("--tls-verify=false");
|
||||
}
|
||||
|
||||
args.push(image);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&args);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Push an image to a registry
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image name
|
||||
/// * `destination` - Destination registry
|
||||
/// * `tls_verify` - Whether to verify TLS
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_push(
|
||||
image: &str,
|
||||
destination: &str,
|
||||
tls_verify: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
let mut args = vec!["push"];
|
||||
|
||||
if !tls_verify {
|
||||
args.push("--tls-verify=false");
|
||||
}
|
||||
|
||||
args.push(image);
|
||||
args.push(destination);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Push an image to a registry with debug output
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image name
|
||||
/// * `destination` - Destination registry
|
||||
/// * `tls_verify` - Whether to verify TLS
|
||||
/// * `debug` - Whether to enable debug output
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_push_with_debug(
|
||||
image: &str,
|
||||
destination: &str,
|
||||
tls_verify: bool,
|
||||
debug: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag
|
||||
set_thread_local_debug(debug);
|
||||
|
||||
let mut args = vec!["push"];
|
||||
|
||||
if !tls_verify {
|
||||
args.push("--tls-verify=false");
|
||||
}
|
||||
|
||||
args.push(image);
|
||||
args.push(destination);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&args);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Tag an image
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image ID or name
|
||||
/// * `new_name` - New tag for the image
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_tag(image: &str, new_name: &str) -> Result<CommandResult, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
execute_buildah_command(&["tag", image, new_name])
|
||||
}
|
||||
|
||||
/// Tag an image with debug output
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `image` - Image ID or name
|
||||
/// * `new_name` - New tag for the image
|
||||
/// * `debug` - Whether to enable debug output
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_tag_with_debug(
|
||||
image: &str,
|
||||
new_name: &str,
|
||||
debug: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag
|
||||
set_thread_local_debug(debug);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&["tag", image, new_name]);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Commit a container to an image with advanced options
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `container` - Container ID or name
|
||||
/// * `image_name` - Name for the new image
|
||||
/// * `format` - Optional format (oci or docker)
|
||||
/// * `squash` - Whether to squash layers
|
||||
/// * `rm` - Whether to remove the container after commit
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_commit(
|
||||
container: &str,
|
||||
image_name: &str,
|
||||
format: Option<&str>,
|
||||
squash: bool,
|
||||
rm: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
let mut args = vec!["commit"];
|
||||
|
||||
if let Some(format_str) = format {
|
||||
args.push("--format");
|
||||
args.push(format_str);
|
||||
}
|
||||
|
||||
if squash {
|
||||
args.push("--squash");
|
||||
}
|
||||
|
||||
if rm {
|
||||
args.push("--rm");
|
||||
}
|
||||
|
||||
args.push(container);
|
||||
args.push(image_name);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Commit a container to an image with advanced options and debug output
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `container` - Container ID or name
|
||||
/// * `image_name` - Name for the new image
|
||||
/// * `format` - Optional format (oci or docker)
|
||||
/// * `squash` - Whether to squash layers
|
||||
/// * `rm` - Whether to remove the container after commit
|
||||
/// * `debug` - Whether to enable debug output
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn image_commit_with_debug(
|
||||
container: &str,
|
||||
image_name: &str,
|
||||
format: Option<&str>,
|
||||
squash: bool,
|
||||
rm: bool,
|
||||
debug: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag
|
||||
set_thread_local_debug(debug);
|
||||
|
||||
let mut args = vec!["commit"];
|
||||
|
||||
if let Some(format_str) = format {
|
||||
args.push("--format");
|
||||
args.push(format_str);
|
||||
}
|
||||
|
||||
if squash {
|
||||
args.push("--squash");
|
||||
}
|
||||
|
||||
if rm {
|
||||
args.push("--rm");
|
||||
}
|
||||
|
||||
args.push(container);
|
||||
args.push(image_name);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&args);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
/// Build an image from a Containerfile/Dockerfile
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `tag` - Optional tag for the image
|
||||
/// * `context_dir` - Directory containing the Containerfile/Dockerfile
|
||||
/// * `file` - Path to the Containerfile/Dockerfile
|
||||
/// * `isolation` - Optional isolation method
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn build(
|
||||
tag: Option<&str>,
|
||||
context_dir: &str,
|
||||
file: &str,
|
||||
isolation: Option<&str>,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Use default debug value (false) for static method
|
||||
let mut args = Vec::new();
|
||||
args.push("build");
|
||||
|
||||
if let Some(tag_value) = tag {
|
||||
args.push("-t");
|
||||
args.push(tag_value);
|
||||
}
|
||||
|
||||
if let Some(isolation_value) = isolation {
|
||||
args.push("--isolation");
|
||||
args.push(isolation_value);
|
||||
}
|
||||
|
||||
args.push("-f");
|
||||
args.push(file);
|
||||
|
||||
args.push(context_dir);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Build an image from a Containerfile/Dockerfile with debug output
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `tag` - Optional tag for the image
|
||||
/// * `context_dir` - Directory containing the Containerfile/Dockerfile
|
||||
/// * `file` - Path to the Containerfile/Dockerfile
|
||||
/// * `isolation` - Optional isolation method
|
||||
/// * `debug` - Whether to enable debug output
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn build_with_debug(
|
||||
tag: Option<&str>,
|
||||
context_dir: &str,
|
||||
file: &str,
|
||||
isolation: Option<&str>,
|
||||
debug: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Save the current debug flag
|
||||
let previous_debug = thread_local_debug();
|
||||
|
||||
// Set the thread-local debug flag
|
||||
set_thread_local_debug(debug);
|
||||
|
||||
let mut args = Vec::new();
|
||||
args.push("build");
|
||||
|
||||
if let Some(tag_value) = tag {
|
||||
args.push("-t");
|
||||
args.push(tag_value);
|
||||
}
|
||||
|
||||
if let Some(isolation_value) = isolation {
|
||||
args.push("--isolation");
|
||||
args.push(isolation_value);
|
||||
}
|
||||
|
||||
args.push("-f");
|
||||
args.push(file);
|
||||
|
||||
args.push(context_dir);
|
||||
|
||||
// Execute the command
|
||||
let result = execute_buildah_command(&args);
|
||||
|
||||
// Restore the previous debug flag
|
||||
set_thread_local_debug(previous_debug);
|
||||
|
||||
result
|
||||
}
|
||||
}
|
97
packages/system/virt/src/buildah/cmd.rs
Normal file
97
packages/system/virt/src/buildah/cmd.rs
Normal file
@@ -0,0 +1,97 @@
|
||||
// Basic buildah operations for container management
|
||||
use super::BuildahError;
|
||||
use sal_process::CommandResult;
|
||||
use std::process::Command;
|
||||
|
||||
/// Execute a buildah command and return the result
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `args` - The command arguments
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn execute_buildah_command(args: &[&str]) -> Result<CommandResult, BuildahError> {
|
||||
// Get the debug flag from thread-local storage
|
||||
let debug = thread_local_debug();
|
||||
|
||||
if debug {
|
||||
println!("Executing buildah command: buildah {}", args.join(" "));
|
||||
}
|
||||
|
||||
let output = Command::new("buildah").args(args).output();
|
||||
|
||||
match output {
|
||||
Ok(output) => {
|
||||
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
|
||||
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
||||
|
||||
let result = CommandResult {
|
||||
stdout,
|
||||
stderr,
|
||||
success: output.status.success(),
|
||||
code: output.status.code().unwrap_or(-1),
|
||||
};
|
||||
|
||||
// Always output stdout/stderr when debug is true
|
||||
if debug {
|
||||
if !result.stdout.is_empty() {
|
||||
println!("Command stdout: {}", result.stdout);
|
||||
}
|
||||
|
||||
if !result.stderr.is_empty() {
|
||||
println!("Command stderr: {}", result.stderr);
|
||||
}
|
||||
|
||||
if result.success {
|
||||
println!("Command succeeded with code {}", result.code);
|
||||
} else {
|
||||
println!("Command failed with code {}", result.code);
|
||||
}
|
||||
}
|
||||
|
||||
if result.success {
|
||||
Ok(result)
|
||||
} else {
|
||||
// If command failed and debug is false, output stderr
|
||||
if !debug {
|
||||
println!(
|
||||
"Command failed with code {}: {}",
|
||||
result.code,
|
||||
result.stderr.trim()
|
||||
);
|
||||
}
|
||||
Err(BuildahError::CommandFailed(format!(
|
||||
"Command failed with code {}: {}",
|
||||
result.code,
|
||||
result.stderr.trim()
|
||||
)))
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
// Always output error information
|
||||
println!("Command execution failed: {}", e);
|
||||
Err(BuildahError::CommandExecutionFailed(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Thread-local storage for debug flag
|
||||
thread_local! {
|
||||
static DEBUG: std::cell::RefCell<bool> = std::cell::RefCell::new(false);
|
||||
}
|
||||
|
||||
/// Set the debug flag for the current thread
|
||||
pub fn set_thread_local_debug(debug: bool) {
|
||||
DEBUG.with(|cell| {
|
||||
*cell.borrow_mut() = debug;
|
||||
});
|
||||
}
|
||||
|
||||
/// Get the debug flag for the current thread
|
||||
pub fn thread_local_debug() -> bool {
|
||||
DEBUG.with(|cell| *cell.borrow())
|
||||
}
|
||||
|
||||
// This function is no longer needed as the debug functionality is now integrated into execute_buildah_command
|
100
packages/system/virt/src/buildah/containers.rs
Normal file
100
packages/system/virt/src/buildah/containers.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
use super::BuildahError;
|
||||
use crate::buildah::execute_buildah_command;
|
||||
use sal_process::CommandResult;
|
||||
|
||||
/// Create a container from an image
|
||||
pub fn from(image: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["from", image])
|
||||
}
|
||||
|
||||
/// Run a command in a container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `container` - The container ID or name
|
||||
/// * `command` - The command to run
|
||||
pub fn run(container: &str, command: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["run", container, "sh", "-c", command])
|
||||
}
|
||||
|
||||
/// Run a command in a container with specified isolation
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `container` - The container ID or name
|
||||
/// * `command` - The command to run
|
||||
/// * `isolation` - Isolation method (e.g., "chroot", "rootless", "oci")
|
||||
pub fn bah_run_with_isolation(
|
||||
container: &str,
|
||||
command: &str,
|
||||
isolation: &str,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&[
|
||||
"run",
|
||||
"--isolation",
|
||||
isolation,
|
||||
container,
|
||||
"sh",
|
||||
"-c",
|
||||
command,
|
||||
])
|
||||
}
|
||||
|
||||
/// Copy files into a container
|
||||
pub fn bah_copy(container: &str, source: &str, dest: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["copy", container, source, dest])
|
||||
}
|
||||
|
||||
pub fn bah_add(container: &str, source: &str, dest: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["add", container, source, dest])
|
||||
}
|
||||
|
||||
/// Commit a container to an image
|
||||
pub fn bah_commit(container: &str, image_name: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["commit", container, image_name])
|
||||
}
|
||||
|
||||
/// Remove a container
|
||||
pub fn bah_remove(container: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["rm", container])
|
||||
}
|
||||
|
||||
/// List containers
|
||||
pub fn bah_list() -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["containers"])
|
||||
}
|
||||
|
||||
/// Build an image from a Containerfile/Dockerfile
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `tag` - Optional tag for the image (e.g., "my-app:latest")
|
||||
/// * `context_dir` - The directory containing the Containerfile/Dockerfile (usually ".")
|
||||
/// * `file` - Optional path to a specific Containerfile/Dockerfile
|
||||
/// * `isolation` - Optional isolation method (e.g., "chroot", "rootless", "oci")
|
||||
pub fn bah_build(
|
||||
tag: Option<&str>,
|
||||
context_dir: &str,
|
||||
file: &str,
|
||||
isolation: Option<&str>,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
let mut args = Vec::new();
|
||||
args.push("build");
|
||||
|
||||
if let Some(tag_value) = tag {
|
||||
args.push("-t");
|
||||
args.push(tag_value);
|
||||
}
|
||||
|
||||
if let Some(isolation_value) = isolation {
|
||||
args.push("--isolation");
|
||||
args.push(isolation_value);
|
||||
}
|
||||
|
||||
args.push("-f");
|
||||
args.push(file);
|
||||
|
||||
args.push(context_dir);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
338
packages/system/virt/src/buildah/containers_test.rs
Normal file
338
packages/system/virt/src/buildah/containers_test.rs
Normal file
@@ -0,0 +1,338 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::buildah::BuildahError;
|
||||
use lazy_static::lazy_static;
|
||||
use sal_process::CommandResult;
|
||||
use std::sync::Mutex;
|
||||
|
||||
// Create a test-specific implementation of the containers module functions
|
||||
// that we can use to verify the correct arguments are passed
|
||||
|
||||
lazy_static! {
|
||||
static ref LAST_COMMAND: Mutex<Vec<String>> = Mutex::new(Vec::new());
|
||||
static ref SHOULD_FAIL: Mutex<bool> = Mutex::new(false);
|
||||
static ref TEST_MUTEX: Mutex<()> = Mutex::new(()); // Add a mutex for test synchronization
|
||||
}
|
||||
|
||||
fn reset_test_state() {
|
||||
let mut cmd = LAST_COMMAND.lock().unwrap();
|
||||
cmd.clear();
|
||||
let mut fail = SHOULD_FAIL.lock().unwrap();
|
||||
*fail = false;
|
||||
}
|
||||
|
||||
fn set_should_fail(fail: bool) {
|
||||
let mut should_fail = SHOULD_FAIL.lock().unwrap();
|
||||
*should_fail = fail;
|
||||
}
|
||||
|
||||
fn get_last_command() -> Vec<String> {
|
||||
let cmd = LAST_COMMAND.lock().unwrap();
|
||||
cmd.clone()
|
||||
}
|
||||
|
||||
// Test-specific implementation of execute_buildah_command
|
||||
fn test_execute_buildah_command(args: &[&str]) -> Result<CommandResult, BuildahError> {
|
||||
// Record the command
|
||||
{
|
||||
let mut cmd = LAST_COMMAND.lock().unwrap();
|
||||
cmd.clear();
|
||||
for arg in args {
|
||||
cmd.push(arg.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we should fail
|
||||
let should_fail = {
|
||||
let fail = SHOULD_FAIL.lock().unwrap();
|
||||
*fail
|
||||
};
|
||||
|
||||
if should_fail {
|
||||
Err(BuildahError::CommandFailed("Command failed".to_string()))
|
||||
} else {
|
||||
Ok(CommandResult {
|
||||
stdout: "mock stdout".to_string(),
|
||||
stderr: "".to_string(),
|
||||
success: true,
|
||||
code: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Test implementations of the container functions
|
||||
fn test_from(image: &str) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["from", image])
|
||||
}
|
||||
|
||||
fn test_run(container: &str, command: &str) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["run", container, "sh", "-c", command])
|
||||
}
|
||||
|
||||
fn test_bah_run_with_isolation(
|
||||
container: &str,
|
||||
command: &str,
|
||||
isolation: &str,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&[
|
||||
"run",
|
||||
"--isolation",
|
||||
isolation,
|
||||
container,
|
||||
"sh",
|
||||
"-c",
|
||||
command,
|
||||
])
|
||||
}
|
||||
|
||||
fn test_bah_copy(
|
||||
container: &str,
|
||||
source: &str,
|
||||
dest: &str,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["copy", container, source, dest])
|
||||
}
|
||||
|
||||
fn test_bah_add(
|
||||
container: &str,
|
||||
source: &str,
|
||||
dest: &str,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["add", container, source, dest])
|
||||
}
|
||||
|
||||
fn test_bah_commit(container: &str, image_name: &str) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["commit", container, image_name])
|
||||
}
|
||||
|
||||
fn test_bah_remove(container: &str) -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["rm", container])
|
||||
}
|
||||
|
||||
fn test_bah_list() -> Result<CommandResult, BuildahError> {
|
||||
test_execute_buildah_command(&["containers"])
|
||||
}
|
||||
|
||||
fn test_bah_build(
|
||||
tag: Option<&str>,
|
||||
context_dir: &str,
|
||||
file: &str,
|
||||
isolation: Option<&str>,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
let mut args = Vec::new();
|
||||
args.push("build");
|
||||
|
||||
if let Some(tag_value) = tag {
|
||||
args.push("-t");
|
||||
args.push(tag_value);
|
||||
}
|
||||
|
||||
if let Some(isolation_value) = isolation {
|
||||
args.push("--isolation");
|
||||
args.push(isolation_value);
|
||||
}
|
||||
|
||||
args.push("-f");
|
||||
args.push(file);
|
||||
|
||||
args.push(context_dir);
|
||||
|
||||
test_execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
// Tests for each function
|
||||
#[test]
|
||||
fn test_from_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let image = "alpine:latest";
|
||||
let result = test_from(image);
|
||||
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(cmd, vec!["from", "alpine:latest"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_run_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let container = "my-container";
|
||||
let command = "echo hello";
|
||||
|
||||
// Test without isolation
|
||||
let result = test_run(container, command);
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(cmd, vec!["run", "my-container", "sh", "-c", "echo hello"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_run_with_isolation_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let container = "my-container";
|
||||
let command = "echo hello";
|
||||
let isolation = "chroot";
|
||||
|
||||
let result = test_bah_run_with_isolation(container, command, isolation);
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(
|
||||
cmd,
|
||||
vec![
|
||||
"run",
|
||||
"--isolation",
|
||||
"chroot",
|
||||
"my-container",
|
||||
"sh",
|
||||
"-c",
|
||||
"echo hello"
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_copy_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let container = "my-container";
|
||||
let source = "/local/path";
|
||||
let dest = "/container/path";
|
||||
let result = test_bah_copy(container, source, dest);
|
||||
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(
|
||||
cmd,
|
||||
vec!["copy", "my-container", "/local/path", "/container/path"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_add_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let container = "my-container";
|
||||
let source = "/local/path";
|
||||
let dest = "/container/path";
|
||||
let result = test_bah_add(container, source, dest);
|
||||
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(
|
||||
cmd,
|
||||
vec!["add", "my-container", "/local/path", "/container/path"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_commit_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let container = "my-container";
|
||||
let image_name = "my-image:latest";
|
||||
let result = test_bah_commit(container, image_name);
|
||||
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(cmd, vec!["commit", "my-container", "my-image:latest"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_remove_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let container = "my-container";
|
||||
let result = test_bah_remove(container);
|
||||
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(cmd, vec!["rm", "my-container"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_list_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
let result = test_bah_list();
|
||||
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(cmd, vec!["containers"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bah_build_function() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
|
||||
// Test with tag, context directory, file, and no isolation
|
||||
let result = test_bah_build(Some("my-app:latest"), ".", "Dockerfile", None);
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(
|
||||
cmd,
|
||||
vec!["build", "-t", "my-app:latest", "-f", "Dockerfile", "."]
|
||||
);
|
||||
|
||||
reset_test_state(); // Reset state between sub-tests
|
||||
|
||||
// Test with tag, context directory, file, and isolation
|
||||
let result = test_bah_build(
|
||||
Some("my-app:latest"),
|
||||
".",
|
||||
"Dockerfile.custom",
|
||||
Some("chroot"),
|
||||
);
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(
|
||||
cmd,
|
||||
vec![
|
||||
"build",
|
||||
"-t",
|
||||
"my-app:latest",
|
||||
"--isolation",
|
||||
"chroot",
|
||||
"-f",
|
||||
"Dockerfile.custom",
|
||||
"."
|
||||
]
|
||||
);
|
||||
|
||||
reset_test_state(); // Reset state between sub-tests
|
||||
|
||||
// Test with just context directory and file
|
||||
let result = test_bah_build(None, ".", "Dockerfile", None);
|
||||
assert!(result.is_ok());
|
||||
let cmd = get_last_command();
|
||||
assert_eq!(cmd, vec!["build", "-f", "Dockerfile", "."]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_error_handling() {
|
||||
let _lock = TEST_MUTEX.lock().unwrap(); // Acquire lock for test
|
||||
reset_test_state();
|
||||
set_should_fail(true);
|
||||
|
||||
let image = "alpine:latest";
|
||||
let result = test_from(image);
|
||||
|
||||
assert!(result.is_err());
|
||||
match result {
|
||||
Err(BuildahError::CommandFailed(msg)) => {
|
||||
assert_eq!(msg, "Command failed");
|
||||
}
|
||||
_ => panic!("Expected CommandFailed error"),
|
||||
}
|
||||
}
|
||||
}
|
89
packages/system/virt/src/buildah/content.rs
Normal file
89
packages/system/virt/src/buildah/content.rs
Normal file
@@ -0,0 +1,89 @@
|
||||
use crate::buildah::{execute_buildah_command, BuildahError};
|
||||
use sal_process::CommandResult;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
/// Functions for working with file content in buildah containers
|
||||
pub struct ContentOperations;
|
||||
|
||||
impl ContentOperations {
|
||||
/// Write content to a file in the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `container_id` - The container ID
|
||||
/// * `content` - The content to write
|
||||
/// * `dest_path` - Destination path in the container
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<CommandResult, BuildahError>` - Command result or error
|
||||
pub fn write_content(
|
||||
container_id: &str,
|
||||
content: &str,
|
||||
dest_path: &str,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
// Create a temporary file
|
||||
let mut temp_file = NamedTempFile::new()
|
||||
.map_err(|e| BuildahError::Other(format!("Failed to create temporary file: {}", e)))?;
|
||||
|
||||
// Write content to the temporary file
|
||||
temp_file.write_all(content.as_bytes()).map_err(|e| {
|
||||
BuildahError::Other(format!("Failed to write to temporary file: {}", e))
|
||||
})?;
|
||||
|
||||
// Flush the file to ensure content is written
|
||||
temp_file
|
||||
.flush()
|
||||
.map_err(|e| BuildahError::Other(format!("Failed to flush temporary file: {}", e)))?;
|
||||
|
||||
// Copy the temporary file to the container
|
||||
let temp_path = temp_file.path().to_string_lossy().to_string();
|
||||
// Use add instead of copy for better handling of paths
|
||||
execute_buildah_command(&["add", container_id, &temp_path, dest_path])
|
||||
}
|
||||
|
||||
/// Read content from a file in the container
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `container_id` - The container ID
|
||||
/// * `source_path` - Source path in the container
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// * `Result<String, BuildahError>` - File content or error
|
||||
pub fn read_content(container_id: &str, source_path: &str) -> Result<String, BuildahError> {
|
||||
// Create a temporary file
|
||||
let temp_file = NamedTempFile::new()
|
||||
.map_err(|e| BuildahError::Other(format!("Failed to create temporary file: {}", e)))?;
|
||||
|
||||
let temp_path = temp_file.path().to_string_lossy().to_string();
|
||||
|
||||
// Copy the file from the container to the temporary file
|
||||
// Use mount to access the container's filesystem
|
||||
let mount_result = execute_buildah_command(&["mount", container_id])?;
|
||||
let mount_point = mount_result.stdout.trim();
|
||||
|
||||
// Construct the full path to the file in the container
|
||||
let full_source_path = format!("{}{}", mount_point, source_path);
|
||||
|
||||
// Copy the file from the mounted container to the temporary file
|
||||
execute_buildah_command(&["copy", container_id, &full_source_path, &temp_path])?;
|
||||
|
||||
// Unmount the container
|
||||
execute_buildah_command(&["umount", container_id])?;
|
||||
|
||||
// Read the content from the temporary file
|
||||
let mut file = File::open(temp_file.path())
|
||||
.map_err(|e| BuildahError::Other(format!("Failed to open temporary file: {}", e)))?;
|
||||
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content).map_err(|e| {
|
||||
BuildahError::Other(format!("Failed to read from temporary file: {}", e))
|
||||
})?;
|
||||
|
||||
Ok(content)
|
||||
}
|
||||
}
|
230
packages/system/virt/src/buildah/images.rs
Normal file
230
packages/system/virt/src/buildah/images.rs
Normal file
@@ -0,0 +1,230 @@
|
||||
use super::BuildahError;
|
||||
use crate::buildah::execute_buildah_command;
|
||||
use sal_process::CommandResult;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{self, Value};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Represents a container image
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Image {
|
||||
/// Image ID
|
||||
pub id: String,
|
||||
/// Image names/tags
|
||||
pub names: Vec<String>,
|
||||
/// Image size
|
||||
pub size: String,
|
||||
/// Creation timestamp
|
||||
pub created: String,
|
||||
}
|
||||
|
||||
/// List images in local storage
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with array of Image objects on success or error details
|
||||
pub fn images() -> Result<Vec<Image>, BuildahError> {
|
||||
let result = execute_buildah_command(&["images", "--json"])?;
|
||||
|
||||
// Try to parse the JSON output
|
||||
match serde_json::from_str::<serde_json::Value>(&result.stdout) {
|
||||
Ok(json) => {
|
||||
if let Value::Array(images_json) = json {
|
||||
let mut images = Vec::new();
|
||||
|
||||
for image_json in images_json {
|
||||
// Extract image ID
|
||||
let id = match image_json.get("id").and_then(|v| v.as_str()) {
|
||||
Some(id) => id.to_string(),
|
||||
None => {
|
||||
return Err(BuildahError::ConversionError(
|
||||
"Missing image ID".to_string(),
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
// Extract image names
|
||||
let names = match image_json.get("names").and_then(|v| v.as_array()) {
|
||||
Some(names_array) => {
|
||||
let mut names_vec = Vec::new();
|
||||
for name_value in names_array {
|
||||
if let Some(name_str) = name_value.as_str() {
|
||||
names_vec.push(name_str.to_string());
|
||||
}
|
||||
}
|
||||
names_vec
|
||||
}
|
||||
None => Vec::new(), // Empty vector if no names found
|
||||
};
|
||||
|
||||
// Extract image size
|
||||
let size = match image_json.get("size").and_then(|v| v.as_str()) {
|
||||
Some(size) => size.to_string(),
|
||||
None => "Unknown".to_string(), // Default value if size not found
|
||||
};
|
||||
|
||||
// Extract creation timestamp
|
||||
let created = match image_json.get("created").and_then(|v| v.as_str()) {
|
||||
Some(created) => created.to_string(),
|
||||
None => "Unknown".to_string(), // Default value if created not found
|
||||
};
|
||||
|
||||
// Create Image struct and add to vector
|
||||
images.push(Image {
|
||||
id,
|
||||
names,
|
||||
size,
|
||||
created,
|
||||
});
|
||||
}
|
||||
|
||||
Ok(images)
|
||||
} else {
|
||||
Err(BuildahError::JsonParseError(
|
||||
"Expected JSON array".to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
Err(e) => Err(BuildahError::JsonParseError(format!(
|
||||
"Failed to parse image list JSON: {}",
|
||||
e
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove one or more images
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `image` - Image ID or name
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with command output or error
|
||||
pub fn image_remove(image: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["rmi", image])
|
||||
}
|
||||
|
||||
/// Push an image to a registry
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `image` - Image name
|
||||
/// * `destination` - Destination (e.g., "docker://registry.example.com/myimage:latest")
|
||||
/// * `tls_verify` - Whether to verify TLS (default: true)
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with command output or error
|
||||
pub fn image_push(
|
||||
image: &str,
|
||||
destination: &str,
|
||||
tls_verify: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
let mut args = vec!["push"];
|
||||
|
||||
if !tls_verify {
|
||||
args.push("--tls-verify=false");
|
||||
}
|
||||
|
||||
args.push(image);
|
||||
args.push(destination);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Add an additional name to a local image
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `image` - Image ID or name
|
||||
/// * `new_name` - New name for the image
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with command output or error
|
||||
pub fn image_tag(image: &str, new_name: &str) -> Result<CommandResult, BuildahError> {
|
||||
execute_buildah_command(&["tag", image, new_name])
|
||||
}
|
||||
|
||||
/// Pull an image from a registry
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `image` - Image name
|
||||
/// * `tls_verify` - Whether to verify TLS (default: true)
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with command output or error
|
||||
pub fn image_pull(image: &str, tls_verify: bool) -> Result<CommandResult, BuildahError> {
|
||||
let mut args = vec!["pull"];
|
||||
|
||||
if !tls_verify {
|
||||
args.push("--tls-verify=false");
|
||||
}
|
||||
|
||||
args.push(image);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Commit a container to an image
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `container` - Container ID or name
|
||||
/// * `image_name` - New name for the image
|
||||
/// * `format` - Optional, format to use for the image (oci or docker)
|
||||
/// * `squash` - Whether to squash layers
|
||||
/// * `rm` - Whether to remove the container after commit
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with command output or error
|
||||
pub fn image_commit(
|
||||
container: &str,
|
||||
image_name: &str,
|
||||
format: Option<&str>,
|
||||
squash: bool,
|
||||
rm: bool,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
let mut args = vec!["commit"];
|
||||
|
||||
if let Some(format_str) = format {
|
||||
args.push("--format");
|
||||
args.push(format_str);
|
||||
}
|
||||
|
||||
if squash {
|
||||
args.push("--squash");
|
||||
}
|
||||
|
||||
if rm {
|
||||
args.push("--rm");
|
||||
}
|
||||
|
||||
args.push(container);
|
||||
args.push(image_name);
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
||||
|
||||
/// Container configuration options
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `container` - Container ID or name
|
||||
/// * `options` - Map of configuration options
|
||||
///
|
||||
/// # Returns
|
||||
/// * Result with command output or error
|
||||
pub fn bah_config(
|
||||
container: &str,
|
||||
options: HashMap<String, String>,
|
||||
) -> Result<CommandResult, BuildahError> {
|
||||
let mut args_owned: Vec<String> = Vec::new();
|
||||
args_owned.push("config".to_string());
|
||||
|
||||
// Process options map
|
||||
for (key, value) in options.iter() {
|
||||
let option_name = format!("--{}", key);
|
||||
args_owned.push(option_name);
|
||||
args_owned.push(value.clone());
|
||||
}
|
||||
|
||||
args_owned.push(container.to_string());
|
||||
|
||||
// Convert Vec<String> to Vec<&str> for execute_buildah_command
|
||||
let args: Vec<&str> = args_owned.iter().map(|s| s.as_str()).collect();
|
||||
|
||||
execute_buildah_command(&args)
|
||||
}
|
59
packages/system/virt/src/buildah/mod.rs
Normal file
59
packages/system/virt/src/buildah/mod.rs
Normal file
@@ -0,0 +1,59 @@
|
||||
mod builder;
|
||||
mod cmd;
|
||||
mod containers;
|
||||
#[cfg(test)]
|
||||
mod containers_test;
|
||||
mod content;
|
||||
mod images;
|
||||
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
|
||||
/// Error type for buildah operations
|
||||
#[derive(Debug)]
|
||||
pub enum BuildahError {
|
||||
/// The buildah command failed to execute
|
||||
CommandExecutionFailed(io::Error),
|
||||
/// The buildah command executed but returned an error
|
||||
CommandFailed(String),
|
||||
/// Failed to parse JSON output
|
||||
JsonParseError(String),
|
||||
/// Failed to convert data
|
||||
ConversionError(String),
|
||||
/// Generic error
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for BuildahError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
BuildahError::CommandExecutionFailed(e) => {
|
||||
write!(f, "Failed to execute buildah command: {}", e)
|
||||
}
|
||||
BuildahError::CommandFailed(e) => write!(f, "Buildah command failed: {}", e),
|
||||
BuildahError::JsonParseError(e) => write!(f, "Failed to parse JSON: {}", e),
|
||||
BuildahError::ConversionError(e) => write!(f, "Conversion error: {}", e),
|
||||
BuildahError::Other(e) => write!(f, "{}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for BuildahError {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
match self {
|
||||
BuildahError::CommandExecutionFailed(e) => Some(e),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
// Re-export the Builder
|
||||
pub use builder::Builder;
|
||||
|
||||
// Re-export existing functions for backward compatibility
|
||||
pub use cmd::*;
|
||||
#[deprecated(since = "0.2.0", note = "Use Builder::new() instead")]
|
||||
pub use containers::*;
|
||||
pub use content::ContentOperations;
|
||||
#[deprecated(since = "0.2.0", note = "Use Builder methods instead")]
|
||||
pub use images::*;
|
Reference in New Issue
Block a user