buildx create
buildx create
is a command to create isolated builder instances for Docker Buildx. It offers a powerful way to manage build environments, allowing users to:
- Isolate builds: Create separate build contexts, preventing conflicts between projects.
- Custom configurations: Customize build environments with specific tools, settings, and dependencies.
- Resource management: Control resource allocation for each builder instance, ensuring optimal performance.
- Multi-arch support: Build for multiple architectures, including cross-compilation, without switching environments.
Options:
buildx create [OPTIONS] [NAME]
[NAME]
: The name of the builder instance to create. If omitted, a default name is generated.-d, --driver DRIVER
: Specify the driver used for the builder instance. Available options include:docker
: Uses Docker Engine as the driver, leveraging existing Docker resources.docker-container
: Launches a Docker container as the builder instance, providing more isolation.kubernetes
: Uses Kubernetes for managing the builder instances, allowing scaling and resource management.ssh
: Creates a remote builder instance on a machine accessible via SSH.
-c, --config CONFIG_FILE
: Path to a YAML file containing builder configuration.-p, --platform [PLATFORM...]
: The platform(s) for which to build. Supported platforms includelinux/amd64
,linux/arm64
,windows/amd64
, etc.-o, --output [OUTPUT...]
: Output formats for the command. Options include:json
: Output in JSON format.table
: Output in table format.
-s, --shared [SHARED...]
: The shared build contexts.-e, --endpoint ENDPOINT
: The endpoint to connect to.-t, --timeout TIMEOUT
: Set a timeout for the operation.-f, --force
: Force creation of a builder instance, overwriting any existing instance with the same name.--no-buildkit
: Disables the use of BuildKit.--buildkit-flags [FLAGS...]
: Pass flags to the BuildKit daemon.--docker-flags [FLAGS...]
: Pass flags to the Docker daemon.--driver-opts [OPTIONS...]
: Pass driver-specific options.--context CONTEXT
: Set the build context.--no-cache
: Disable the use of build cache.--cache-from [CACHE_SOURCE...]
: Specifies where to pull cached build artifacts.--cache-to [CACHE_DESTINATION...]
: Specifies where to push cached build artifacts.--network NETWORK
: Define the network for the builder instance.--volumes [VOLUME...]
: Mount volumes into the builder instance.--labels [LABEL...]
: Set labels for the builder instance.--ssh-user USER
: The SSH username for accessing the remote builder instance.--ssh-port PORT
: The SSH port to connect to.--ssh-identity [FILE...]
: The path to the SSH identity file.--ssh-timeout TIMEOUT
: The timeout for the SSH connection.
Examples:
1. Creating a builder instance with the docker
driver:
buildx create --driver docker --name my-builder
2. Creating a builder instance using a custom configuration file:
buildx create --config my-builder-config.yaml --name my-builder
3. Creating a builder instance with multi-arch support:
buildx create --platform linux/amd64,linux/arm64 --name my-builder
4. Creating a builder instance with a custom network:
buildx create --network my-network --name my-builder
5. Creating a builder instance using the ssh
driver:
buildx create --driver ssh --name my-builder --ssh-user my-user --ssh-port 22 --ssh-identity my-key.pem
Source:
Related commands: