You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
298 lines
9.4 KiB
YAML
298 lines
9.4 KiB
YAML
3 years ago
|
command: docker buildx create
|
||
|
short: Create a new builder instance
|
||
|
long: |-
|
||
|
Create makes a new builder instance pointing to a docker context or endpoint,
|
||
|
where context is the name of a context from `docker context ls` and endpoint is
|
||
|
the address for docker socket (eg. `DOCKER_HOST` value).
|
||
|
|
||
|
By default, the current Docker configuration is used for determining the
|
||
|
context/endpoint value.
|
||
|
|
||
|
Builder instances are isolated environments where builds can be invoked. All
|
||
|
Docker contexts also get the default builder instance.
|
||
|
usage: docker buildx create [OPTIONS] [CONTEXT|ENDPOINT]
|
||
|
pname: docker buildx
|
||
|
plink: docker_buildx.yaml
|
||
|
options:
|
||
|
- option: append
|
||
|
value_type: bool
|
||
|
default_value: "false"
|
||
|
description: Append a node to builder instead of changing it
|
||
|
details_url: '#append'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: bootstrap
|
||
|
value_type: bool
|
||
|
default_value: "false"
|
||
|
description: Boot builder after creation
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: buildkitd-flags
|
||
|
value_type: string
|
||
|
description: Flags for buildkitd daemon
|
||
|
details_url: '#buildkitd-flags'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: config
|
||
|
value_type: string
|
||
|
description: BuildKit config file
|
||
|
details_url: '#config'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: driver
|
||
|
value_type: string
|
||
|
description: 'Driver to use (available: [])'
|
||
|
details_url: '#driver'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: driver-opt
|
||
|
value_type: stringArray
|
||
|
default_value: '[]'
|
||
|
description: Options for the driver
|
||
|
details_url: '#driver-opt'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: leave
|
||
|
value_type: bool
|
||
|
default_value: "false"
|
||
|
description: Remove a node from builder instead of changing it
|
||
|
details_url: '#leave'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: name
|
||
|
value_type: string
|
||
|
description: Builder instance name
|
||
|
details_url: '#name'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: node
|
||
|
value_type: string
|
||
|
description: Create/modify node with given name
|
||
|
details_url: '#node'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: platform
|
||
|
value_type: stringArray
|
||
|
default_value: '[]'
|
||
|
description: Fixed platforms for current node
|
||
|
details_url: '#platform'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
- option: use
|
||
|
value_type: bool
|
||
|
default_value: "false"
|
||
|
description: Set the current builder instance
|
||
|
details_url: '#use'
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
inherited_options:
|
||
|
- option: builder
|
||
|
value_type: string
|
||
|
description: Override the configured builder instance
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
examples: |-
|
||
|
### Append a new node to an existing builder (--append) {#append}
|
||
|
|
||
|
The `--append` flag changes the action of the command to append a new node to an
|
||
|
existing builder specified by `--name`. Buildx will choose an appropriate node
|
||
|
for a build based on the platforms it supports.
|
||
|
|
||
|
**Examples**
|
||
|
|
||
|
```console
|
||
|
$ docker buildx create mycontext1
|
||
|
eager_beaver
|
||
|
|
||
|
$ docker buildx create --name eager_beaver --append mycontext2
|
||
|
eager_beaver
|
||
|
```
|
||
|
|
||
|
### Specify options for the buildkitd daemon (--buildkitd-flags) {#buildkitd-flags}
|
||
|
|
||
|
```
|
||
|
--buildkitd-flags FLAGS
|
||
|
```
|
||
|
|
||
|
Adds flags when starting the buildkitd daemon. They take precedence over the
|
||
|
configuration file specified by [`--config`](#--config-file). See `buildkitd --help`
|
||
|
for the available flags.
|
||
|
|
||
|
**Example**
|
||
|
|
||
|
```
|
||
|
--buildkitd-flags '--debug --debugaddr 0.0.0.0:6666'
|
||
|
```
|
||
|
|
||
|
### Specify a configuration file for the buildkitd daemon (--config) {#config}
|
||
|
|
||
|
```
|
||
|
--config FILE
|
||
|
```
|
||
|
|
||
|
Specifies the configuration file for the buildkitd daemon to use. The configuration
|
||
|
can be overridden by [`--buildkitd-flags`](#--buildkitd-flags-flags).
|
||
|
See an [example buildkitd configuration file](https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md).
|
||
|
|
||
|
### Set the builder driver to use (--driver) {#driver}
|
||
|
|
||
|
```
|
||
|
--driver DRIVER
|
||
|
```
|
||
|
|
||
|
Sets the builder driver to be used. There are two available drivers, each have
|
||
|
their own specificities.
|
||
|
|
||
|
#### `docker` driver
|
||
|
|
||
|
Uses the builder that is built into the docker daemon. With this driver,
|
||
|
the [`--load`](buildx_build.md#--load) flag is implied by default on
|
||
|
`buildx build`. However, building multi-platform images or exporting cache is
|
||
|
not currently supported.
|
||
|
|
||
|
#### `docker-container` driver
|
||
|
|
||
|
Uses a BuildKit container that will be spawned via docker. With this driver,
|
||
|
both building multi-platform images and exporting cache are supported.
|
||
|
|
||
|
Unlike `docker` driver, built images will not automatically appear in
|
||
|
`docker images` and [`build --load`](buildx_build.md#--load) needs to be used
|
||
|
to achieve that.
|
||
|
|
||
|
#### `kubernetes` driver
|
||
|
|
||
|
Uses a kubernetes pods. With this driver, you can spin up pods with defined
|
||
|
BuildKit container image to build your images.
|
||
|
|
||
|
Unlike `docker` driver, built images will not automatically appear in
|
||
|
`docker images` and [`build --load`](buildx_build.md#--load) needs to be used
|
||
|
to achieve that.
|
||
|
|
||
|
### Set additional driver-specific options (--driver-opt) {#driver-opt}
|
||
|
|
||
|
```
|
||
|
--driver-opt OPTIONS
|
||
|
```
|
||
|
|
||
|
Passes additional driver-specific options. Details for each driver:
|
||
|
|
||
|
- `docker` - No driver options
|
||
|
- `docker-container`
|
||
|
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
||
|
- `network=NETMODE` - Sets the network mode for running the buildkit container.
|
||
|
- Example:
|
||
|
|
||
|
```console
|
||
|
--driver docker-container --driver-opt image=moby/buildkit:master,network=host
|
||
|
```
|
||
|
- `kubernetes`
|
||
|
- `image=IMAGE` - Sets the container image to be used for running buildkit.
|
||
|
- `namespace=NS` - Sets the Kubernetes namespace. Defaults to the current namespace.
|
||
|
- `replicas=N` - Sets the number of `Pod` replicas. Defaults to 1.
|
||
|
- `requests.cpu` - Sets the request CPU value specified in units of Kubernetes CPU. Example `requests.cpu=100m`, `requests.cpu=2`
|
||
|
- `requests.memory` - Sets the request memory value specified in bytes or with a valid suffix. Example `requests.memory=500Mi`, `requests.memory=4G`
|
||
|
- `limits.cpu` - Sets the limit CPU value specified in units of Kubernetes CPU. Example `limits.cpu=100m`, `limits.cpu=2`
|
||
|
- `limits.memory` - Sets the limit memory value specified in bytes or with a valid suffix. Example `limits.memory=500Mi`, `limits.memory=4G`
|
||
|
- `nodeselector="label1=value1,label2=value2"` - Sets the kv of `Pod` nodeSelector. No Defaults. Example `nodeselector=kubernetes.io/arch=arm64`
|
||
|
- `rootless=(true|false)` - Run the container as a non-root user without `securityContext.privileged`. [Using Ubuntu host kernel is recommended](https://github.com/moby/buildkit/blob/master/docs/rootless.md). Defaults to false.
|
||
|
- `loadbalance=(sticky|random)` - Load-balancing strategy. If set to "sticky", the pod is chosen using the hash of the context path. Defaults to "sticky"
|
||
|
- `qemu.install=(true|false)` - Install QEMU emulation for multi platforms support.
|
||
|
- `qemu.image=IMAGE` - Sets the QEMU emulation image. Defaults to `tonistiigi/binfmt:latest`
|
||
|
|
||
|
### Remove a node from a builder (--leave) {#leave}
|
||
|
|
||
|
The `--leave` flag changes the action of the command to remove a node from a
|
||
|
builder. The builder needs to be specified with `--name` and node that is removed
|
||
|
is set with `--node`.
|
||
|
|
||
|
**Examples**
|
||
|
|
||
|
```console
|
||
|
$ docker buildx create --name mybuilder --node mybuilder0 --leave
|
||
|
```
|
||
|
|
||
|
### Specify the name of the builder (--name) {#name}
|
||
|
|
||
|
```
|
||
|
--name NAME
|
||
|
```
|
||
|
|
||
|
The `--name` flag specifies the name of the builder to be created or modified.
|
||
|
If none is specified, one will be automatically generated.
|
||
|
|
||
|
### Specify the name of the node (--node) {#node}
|
||
|
|
||
|
```
|
||
|
--node NODE
|
||
|
```
|
||
|
|
||
|
The `--node` flag specifies the name of the node to be created or modified. If
|
||
|
none is specified, it is the name of the builder it belongs to, with an index
|
||
|
number suffix.
|
||
|
|
||
|
### Set the platforms supported by the node {#platform}
|
||
|
|
||
|
```
|
||
|
--platform PLATFORMS
|
||
|
```
|
||
|
|
||
|
The `--platform` flag sets the platforms supported by the node. It expects a
|
||
|
comma-separated list of platforms of the form OS/architecture/variant. The node
|
||
|
will also automatically detect the platforms it supports, but manual values take
|
||
|
priority over the detected ones and can be used when multiple nodes support
|
||
|
building for the same platform.
|
||
|
|
||
|
**Examples**
|
||
|
|
||
|
```console
|
||
|
$ docker buildx create --platform linux/amd64
|
||
|
$ docker buildx create --platform linux/arm64,linux/arm/v8
|
||
|
```
|
||
|
|
||
|
### Automatically switch to the newly created builder {#use}
|
||
|
|
||
|
The `--use` flag automatically switches the current builder to the newly created
|
||
|
one. Equivalent to running `docker buildx use $(docker buildx create ...)`.
|
||
|
deprecated: false
|
||
|
experimental: false
|
||
|
experimentalcli: false
|
||
|
kubernetes: false
|
||
|
swarm: false
|
||
|
|