commit
0147b92230
@ -0,0 +1,198 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/docker/buildx/commands"
|
||||||
|
"github.com/docker/cli/cli/command"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/pflag"
|
||||||
|
)
|
||||||
|
|
||||||
|
const descriptionSourcePath = "docs/reference/"
|
||||||
|
|
||||||
|
func generateDocs(opts *options) error {
|
||||||
|
dockerCLI, err := command.NewDockerCli()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "docker [OPTIONS] COMMAND [ARG...]",
|
||||||
|
Short: "The base command for the Docker CLI.",
|
||||||
|
}
|
||||||
|
cmd.AddCommand(commands.NewRootCmd("buildx", true, dockerCLI))
|
||||||
|
return genCmd(cmd, opts.target)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMDFilename(cmd *cobra.Command) string {
|
||||||
|
name := cmd.CommandPath()
|
||||||
|
if i := strings.Index(name, " "); i >= 0 {
|
||||||
|
name = name[i+1:]
|
||||||
|
}
|
||||||
|
return strings.ReplaceAll(name, " ", "_") + ".md"
|
||||||
|
}
|
||||||
|
|
||||||
|
func genCmd(cmd *cobra.Command, dir string) error {
|
||||||
|
for _, c := range cmd.Commands() {
|
||||||
|
if err := genCmd(c, dir); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !cmd.HasParent() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
mdFile := getMDFilename(cmd)
|
||||||
|
fullPath := filepath.Join(dir, mdFile)
|
||||||
|
|
||||||
|
content, err := ioutil.ReadFile(fullPath)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
|
return errors.Wrapf(err, "%s does not exist", mdFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cs := string(content)
|
||||||
|
|
||||||
|
markerStart := "<!---MARKER_GEN_START-->"
|
||||||
|
markerEnd := "<!---MARKER_GEN_END-->"
|
||||||
|
|
||||||
|
start := strings.Index(cs, markerStart)
|
||||||
|
end := strings.Index(cs, markerEnd)
|
||||||
|
|
||||||
|
if start == -1 {
|
||||||
|
return errors.Errorf("no start marker in %s", mdFile)
|
||||||
|
}
|
||||||
|
if end == -1 {
|
||||||
|
return errors.Errorf("no end marker in %s", mdFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := cmdOutput(cmd, cs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cont := cs[:start] + markerStart + "\n" + out + "\n" + cs[end:]
|
||||||
|
|
||||||
|
fi, err := os.Stat(fullPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(fullPath, []byte(cont), fi.Mode()); err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to write %s", fullPath)
|
||||||
|
}
|
||||||
|
log.Printf("updated %s", fullPath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeLink(txt, link string, f *pflag.Flag, isAnchor bool) string {
|
||||||
|
link = "#" + link
|
||||||
|
annotations, ok := f.Annotations["docs.external.url"]
|
||||||
|
if ok && len(annotations) > 0 {
|
||||||
|
link = annotations[0]
|
||||||
|
} else {
|
||||||
|
if !isAnchor {
|
||||||
|
return txt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "[" + txt + "](" + link + ")"
|
||||||
|
}
|
||||||
|
|
||||||
|
func cmdOutput(cmd *cobra.Command, old string) (string, error) {
|
||||||
|
b := &strings.Builder{}
|
||||||
|
|
||||||
|
desc := cmd.Short
|
||||||
|
if cmd.Long != "" {
|
||||||
|
desc = cmd.Long
|
||||||
|
}
|
||||||
|
if desc != "" {
|
||||||
|
fmt.Fprintf(b, "%s\n\n", desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(cmd.Aliases) != 0 {
|
||||||
|
fmt.Fprintf(b, "### Aliases\n\n`%s`", cmd.Name())
|
||||||
|
for _, a := range cmd.Aliases {
|
||||||
|
fmt.Fprintf(b, ", `%s`", a)
|
||||||
|
}
|
||||||
|
fmt.Fprint(b, "\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(cmd.Commands()) != 0 {
|
||||||
|
fmt.Fprint(b, "### Subcommands\n\n")
|
||||||
|
fmt.Fprint(b, "| Name | Description |\n")
|
||||||
|
fmt.Fprint(b, "| --- | --- |\n")
|
||||||
|
for _, c := range cmd.Commands() {
|
||||||
|
fmt.Fprintf(b, "| [`%s`](%s) | %s |\n", c.Name(), getMDFilename(c), c.Short)
|
||||||
|
}
|
||||||
|
fmt.Fprint(b, "\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
hasFlags := cmd.Flags().HasAvailableFlags()
|
||||||
|
|
||||||
|
cmd.Flags().AddFlagSet(cmd.InheritedFlags())
|
||||||
|
|
||||||
|
if hasFlags {
|
||||||
|
fmt.Fprint(b, "### Options\n\n")
|
||||||
|
fmt.Fprint(b, "| Name | Description |\n")
|
||||||
|
fmt.Fprint(b, "| --- | --- |\n")
|
||||||
|
|
||||||
|
cmd.Flags().VisitAll(func(f *pflag.Flag) {
|
||||||
|
if f.Hidden {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isLink := strings.Contains(old, "<a name=\""+f.Name+"\"></a>")
|
||||||
|
fmt.Fprint(b, "| ")
|
||||||
|
if f.Shorthand != "" {
|
||||||
|
name := "`-" + f.Shorthand + "`"
|
||||||
|
name = makeLink(name, f.Name, f, isLink)
|
||||||
|
fmt.Fprintf(b, "%s, ", name)
|
||||||
|
}
|
||||||
|
name := "`--" + f.Name
|
||||||
|
if f.Value.Type() != "bool" {
|
||||||
|
name += " " + f.Value.Type()
|
||||||
|
}
|
||||||
|
name += "`"
|
||||||
|
name = makeLink(name, f.Name, f, isLink)
|
||||||
|
fmt.Fprintf(b, "%s | %s |\n", name, f.Usage)
|
||||||
|
})
|
||||||
|
fmt.Fprintln(b, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type options struct {
|
||||||
|
target string
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseArgs() (*options, error) {
|
||||||
|
opts := &options{}
|
||||||
|
flags := pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError)
|
||||||
|
flags.StringVar(&opts.target, "target", descriptionSourcePath, "Docs directory")
|
||||||
|
err := flags.Parse(os.Args[1:])
|
||||||
|
return opts, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if err := run(); err != nil {
|
||||||
|
log.Printf("error: %+v", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func run() error {
|
||||||
|
opts, err := parseArgs()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := generateDocs(opts); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
# buildx
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx [OPTIONS] COMMAND
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Build with BuildKit
|
||||||
|
|
||||||
|
### Subcommands
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [`bake`](buildx_bake.md) | Build from a file |
|
||||||
|
| [`build`](buildx_build.md) | Start a build |
|
||||||
|
| [`create`](buildx_create.md) | Create a new builder instance |
|
||||||
|
| [`du`](buildx_du.md) | Disk usage |
|
||||||
|
| [`imagetools`](buildx_imagetools.md) | Commands to work on images in registry |
|
||||||
|
| [`inspect`](buildx_inspect.md) | Inspect current builder instance |
|
||||||
|
| [`install`](buildx_install.md) | Install buildx as a 'docker builder' alias |
|
||||||
|
| [`ls`](buildx_ls.md) | List builder instances |
|
||||||
|
| [`prune`](buildx_prune.md) | Remove build cache |
|
||||||
|
| [`rm`](buildx_rm.md) | Remove a builder instance |
|
||||||
|
| [`stop`](buildx_stop.md) | Stop builder instance |
|
||||||
|
| [`uninstall`](buildx_uninstall.md) | Uninstall the 'docker builder' alias |
|
||||||
|
| [`use`](buildx_use.md) | Set the current builder instance |
|
||||||
|
| [`version`](buildx_version.md) | Show buildx version information |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
@ -0,0 +1,369 @@
|
|||||||
|
# buildx bake
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx bake [OPTIONS] [TARGET...]
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Build from a file
|
||||||
|
|
||||||
|
### Aliases
|
||||||
|
|
||||||
|
`bake`, `f`
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| [`-f`](#file), [`--file stringArray`](#file) | Build definition file |
|
||||||
|
| `--load` | Shorthand for --set=*.output=type=docker |
|
||||||
|
| [`--no-cache`](#no-cache) | Do not use cache when building the image |
|
||||||
|
| [`--print`](#print) | Print the options without building |
|
||||||
|
| [`--progress string`](#progress) | Set type of progress output (auto, plain, tty). Use plain to show container output |
|
||||||
|
| [`--pull`](#pull) | Always attempt to pull a newer version of the image |
|
||||||
|
| `--push` | Shorthand for --set=*.output=type=registry |
|
||||||
|
| [`--set stringArray`](#set) | Override target value (eg: targetpattern.key=value) |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Bake is a high-level build command. Each specified target will run in parallel
|
||||||
|
as part of the build.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### <a name="file"></a> Specify a build definition file (-f, --file)
|
||||||
|
|
||||||
|
By default, `buildx bake` looks for build definition files in the current directory,
|
||||||
|
the following are parsed:
|
||||||
|
|
||||||
|
- `docker-compose.yml`
|
||||||
|
- `docker-compose.yaml`
|
||||||
|
- `docker-bake.json`
|
||||||
|
- `docker-bake.override.json`
|
||||||
|
- `docker-bake.hcl`
|
||||||
|
- `docker-bake.override.hcl`
|
||||||
|
|
||||||
|
Use the `-f` / `--file` option to specify the build definition file to use. The
|
||||||
|
file can be a Docker Compose, JSON or HCL file. If multiple files are specified
|
||||||
|
they are all read and configurations are combined.
|
||||||
|
|
||||||
|
The following example uses a Docker Compose file named `docker-compose.dev.yaml`
|
||||||
|
as build definition file, and builds all targets in the file:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx bake -f docker-compose.dev.yaml
|
||||||
|
|
||||||
|
[+] Building 66.3s (30/30) FINISHED
|
||||||
|
=> [frontend internal] load build definition from Dockerfile 0.1s
|
||||||
|
=> => transferring dockerfile: 36B 0.0s
|
||||||
|
=> [backend internal] load build definition from Dockerfile 0.2s
|
||||||
|
=> => transferring dockerfile: 3.73kB 0.0s
|
||||||
|
=> [database internal] load build definition from Dockerfile 0.1s
|
||||||
|
=> => transferring dockerfile: 5.77kB 0.0s
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Pass the names of the targets to build, to build only specific target(s). The
|
||||||
|
following example builds the `backend` and `database` targets that are defined
|
||||||
|
in the `docker-compose.dev.yaml` file, skipping the build for the `frontend`
|
||||||
|
target:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx bake -f docker-compose.dev.yaml backend database
|
||||||
|
|
||||||
|
[+] Building 2.4s (13/13) FINISHED
|
||||||
|
=> [backend internal] load build definition from Dockerfile 0.1s
|
||||||
|
=> => transferring dockerfile: 81B 0.0s
|
||||||
|
=> [database internal] load build definition from Dockerfile 0.2s
|
||||||
|
=> => transferring dockerfile: 36B 0.0s
|
||||||
|
=> [backend internal] load .dockerignore 0.3s
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="no-cache"></a> Do not use cache when building the image (--no-cache)
|
||||||
|
|
||||||
|
Same as `build --no-cache`. Do not use cache when building the image.
|
||||||
|
|
||||||
|
### <a name="print"></a> Print the options without building (--print)
|
||||||
|
|
||||||
|
Prints the resulting options of the targets desired to be built, in a JSON format,
|
||||||
|
without starting a build.
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx bake -f docker-bake.hcl --print db
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"db": {
|
||||||
|
"context": "./",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"tags": [
|
||||||
|
"docker.io/tiborvass/db"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="progress"></a> Set type of progress output (--progress)
|
||||||
|
|
||||||
|
Same as `build --progress`. Set type of progress output (auto, plain, tty). Use
|
||||||
|
plain to show container output (default "auto").
|
||||||
|
|
||||||
|
The following example uses `plain` output during the build:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx bake --progress=plain
|
||||||
|
|
||||||
|
#2 [backend internal] load build definition from Dockerfile.test
|
||||||
|
#2 sha256:de70cb0bb6ed8044f7b9b1b53b67f624e2ccfb93d96bb48b70c1fba562489618
|
||||||
|
#2 ...
|
||||||
|
|
||||||
|
#1 [database internal] load build definition from Dockerfile.test
|
||||||
|
#1 sha256:453cb50abd941762900a1212657a35fc4aad107f5d180b0ee9d93d6b74481bce
|
||||||
|
#1 transferring dockerfile: 36B done
|
||||||
|
#1 DONE 0.1s
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### <a name="pull"></a> Always attempt to pull a newer version of the image (--pull)
|
||||||
|
|
||||||
|
Same as `build --pull`.
|
||||||
|
|
||||||
|
### <a name="set"></a> Override target configurations from command line (--set)
|
||||||
|
|
||||||
|
```
|
||||||
|
--set targetpattern.key[.subkey]=value
|
||||||
|
```
|
||||||
|
|
||||||
|
Override target configurations from command line. The pattern matching syntax is
|
||||||
|
defined in https://golang.org/pkg/path/#Match.
|
||||||
|
|
||||||
|
**Examples**
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx bake --set target.args.mybuildarg=value
|
||||||
|
$ docker buildx bake --set target.platform=linux/arm64
|
||||||
|
$ docker buildx bake --set foo*.args.mybuildarg=value # overrides build arg for all targets starting with 'foo'
|
||||||
|
$ docker buildx bake --set *.platform=linux/arm64 # overrides platform for all targets
|
||||||
|
$ docker buildx bake --set foo*.no-cache # bypass caching only for targets starting with 'foo'
|
||||||
|
```
|
||||||
|
|
||||||
|
Complete list of overridable fields:
|
||||||
|
args, cache-from, cache-to, context, dockerfile, labels, no-cache, output, platform,
|
||||||
|
pull, secrets, ssh, tags, target
|
||||||
|
|
||||||
|
### File definition
|
||||||
|
|
||||||
|
In addition to compose files, bake supports a JSON and an equivalent HCL file
|
||||||
|
format for defining build groups and targets.
|
||||||
|
|
||||||
|
A target reflects a single docker build invocation with the same options that
|
||||||
|
you would specify for `docker build`. A group is a grouping of targets.
|
||||||
|
|
||||||
|
Multiple files can include the same target and final build options will be
|
||||||
|
determined by merging them together.
|
||||||
|
|
||||||
|
In the case of compose files, each service corresponds to a target.
|
||||||
|
|
||||||
|
A group can specify its list of targets with the `targets` option. A target can
|
||||||
|
inherit build options by setting the `inherits` option to the list of targets or
|
||||||
|
groups to inherit from.
|
||||||
|
|
||||||
|
Note: Design of bake command is work in progress, the user experience may change
|
||||||
|
based on feedback.
|
||||||
|
|
||||||
|
|
||||||
|
**Example HCL definition**
|
||||||
|
|
||||||
|
```hcl
|
||||||
|
group "default" {
|
||||||
|
targets = ["db", "webapp-dev"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "webapp-dev" {
|
||||||
|
dockerfile = "Dockerfile.webapp"
|
||||||
|
tags = ["docker.io/username/webapp"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "webapp-release" {
|
||||||
|
inherits = ["webapp-dev"]
|
||||||
|
platforms = ["linux/amd64", "linux/arm64"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "db" {
|
||||||
|
dockerfile = "Dockerfile.db"
|
||||||
|
tags = ["docker.io/username/db"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Complete list of valid target fields:
|
||||||
|
|
||||||
|
`args`, `cache-from`, `cache-to`, `context`, `dockerfile`, `inherits`, `labels`,
|
||||||
|
`no-cache`, `output`, `platform`, `pull`, `secrets`, `ssh`, `tags`, `target`
|
||||||
|
|
||||||
|
### HCL variables and functions
|
||||||
|
|
||||||
|
Similar to how Terraform provides a way to [define variables](https://www.terraform.io/docs/configuration/variables.html#declaring-an-input-variable),
|
||||||
|
the HCL file format also supports variable block definitions. These can be used
|
||||||
|
to define variables with values provided by the current environment, or a default
|
||||||
|
value when unset.
|
||||||
|
|
||||||
|
|
||||||
|
Example of using interpolation to tag an image with the git sha:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cat <<'EOF' > docker-bake.hcl
|
||||||
|
variable "TAG" {
|
||||||
|
default = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = ["webapp"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "webapp" {
|
||||||
|
tags = ["docker.io/username/webapp:${TAG}"]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$ docker buildx bake --print webapp
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"webapp": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"tags": [
|
||||||
|
"docker.io/username/webapp:latest"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ TAG=$(git rev-parse --short HEAD) docker buildx bake --print webapp
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"webapp": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"tags": [
|
||||||
|
"docker.io/username/webapp:985e9e9"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
A [set of generally useful functions](https://github.com/docker/buildx/blob/master/bake/hcl.go#L19-L65)
|
||||||
|
provided by [go-cty](https://github.com/zclconf/go-cty/tree/master/cty/function/stdlib)
|
||||||
|
are available for use in HCL files. In addition, [user defined functions](https://github.com/hashicorp/hcl/tree/hcl2/ext/userfunc)
|
||||||
|
are also supported.
|
||||||
|
|
||||||
|
Example of using the `add` function:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cat <<'EOF' > docker-bake.hcl
|
||||||
|
variable "TAG" {
|
||||||
|
default = "latest"
|
||||||
|
}
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = ["webapp"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "webapp" {
|
||||||
|
args = {
|
||||||
|
buildno = "${add(123, 1)}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$ docker buildx bake --print webapp
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"webapp": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"args": {
|
||||||
|
"buildno": "124"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Example of defining an `increment` function:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cat <<'EOF' > docker-bake.hcl
|
||||||
|
function "increment" {
|
||||||
|
params = [number]
|
||||||
|
result = number + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = ["webapp"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "webapp" {
|
||||||
|
args = {
|
||||||
|
buildno = "${increment(123)}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$ docker buildx bake --print webapp
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"webapp": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"args": {
|
||||||
|
"buildno": "124"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Example of only adding tags if a variable is not empty using an `notequal`
|
||||||
|
function:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ cat <<'EOF' > docker-bake.hcl
|
||||||
|
variable "TAG" {default="" }
|
||||||
|
|
||||||
|
group "default" {
|
||||||
|
targets = [
|
||||||
|
"webapp",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "webapp" {
|
||||||
|
context="."
|
||||||
|
dockerfile="Dockerfile"
|
||||||
|
tags = [
|
||||||
|
"my-image:latest",
|
||||||
|
notequal("",TAG) ? "my-image:${TAG}": "",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
$ docker buildx bake --print webapp
|
||||||
|
{
|
||||||
|
"target": {
|
||||||
|
"webapp": {
|
||||||
|
"context": ".",
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
"tags": [
|
||||||
|
"my-image:latest"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
@ -0,0 +1,185 @@
|
|||||||
|
# buildx create
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx create [OPTIONS] [CONTEXT|ENDPOINT]
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Create a new builder instance
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [`--append`](#append) | Append a node to builder instead of changing it |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| [`--buildkitd-flags string`](#buildkitd-flags) | Flags for buildkitd daemon |
|
||||||
|
| [`--config string`](#config) | BuildKit config file |
|
||||||
|
| [`--driver string`](#driver) | Driver to use (available: []) |
|
||||||
|
| [`--driver-opt stringArray`](#driver-opt) | Options for the driver |
|
||||||
|
| [`--leave`](#leave) | Remove a node from builder instead of changing it |
|
||||||
|
| [`--name string`](#name) | Builder instance name |
|
||||||
|
| [`--node string`](#node) | Create/modify node with given name |
|
||||||
|
| [`--platform stringArray`](#platform) | Fixed platforms for current node |
|
||||||
|
| [`--use`](#use) | Set the current builder instance |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### <a name="append"></a> Append a new node to an existing builder (--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
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="buildkitd-flags"></a> Specify options for the buildkitd daemon (--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'
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="config"></a> Specify a configuration file for the buildkitd daemon (--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).
|
||||||
|
|
||||||
|
### <a name="driver"></a> Set the builder driver to use (--driver)
|
||||||
|
|
||||||
|
```
|
||||||
|
--driver DRIVER
|
||||||
|
```
|
||||||
|
|
||||||
|
Sets the builder driver to be used. There are two available drivers, each have
|
||||||
|
their own specificities.
|
||||||
|
|
||||||
|
- `docker` - 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` - Uses a buildkit container that will be spawned via docker.
|
||||||
|
With this driver, both building multi-platform images and exporting cache are
|
||||||
|
supported. However, images built will not automatically appear in `docker images`
|
||||||
|
(see [`build --load`](buildx_build.md#--load)).
|
||||||
|
- `kubernetes` - Uses a kubernetes pods. With this driver, you can spin up pods
|
||||||
|
with defined buildkit container image to build your images.
|
||||||
|
|
||||||
|
|
||||||
|
### <a name="driver-opt"></a> Set additional driver-specific options (--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.
|
||||||
|
- `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"
|
||||||
|
|
||||||
|
### <a name="leave"></a> Remove a node from a builder (--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
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="name"></a> Specify the name of the builder (--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.
|
||||||
|
|
||||||
|
### <a name="node"></a> Specify the name of the 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.
|
||||||
|
|
||||||
|
### <a name="platform"></a> Set the platforms supported by the node
|
||||||
|
|
||||||
|
```
|
||||||
|
--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
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="use"></a> Automatically switch to the newly created builder
|
||||||
|
|
||||||
|
The `--use` flag automatically switches the current builder to the newly created
|
||||||
|
one. Equivalent to running `docker buildx use $(docker buildx create ...)`.
|
@ -0,0 +1,19 @@
|
|||||||
|
# buildx du
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx du
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Disk usage
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| `--filter filter` | Provide filter values |
|
||||||
|
| `--verbose` | Provide a more verbose output |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
@ -0,0 +1,24 @@
|
|||||||
|
# buildx imagetools
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx imagetools [OPTIONS] COMMAND
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Commands to work on images in registry
|
||||||
|
|
||||||
|
### Subcommands
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [`create`](buildx_imagetools_create.md) | Create a new image based on source images |
|
||||||
|
| [`inspect`](buildx_imagetools_inspect.md) | Show details of image in the registry |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Imagetools contains commands for working with manifest lists in the registry.
|
||||||
|
These commands are useful for inspecting multi-platform build results.
|
@ -0,0 +1,67 @@
|
|||||||
|
# buildx imagetools create
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx imagetools create [OPTIONS] [SOURCE] [SOURCE...]
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Create a new image based on source images
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [`--append`](#append) | Append to existing manifest |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| [`--dry-run`](#dry-run) | Show final image instead of pushing |
|
||||||
|
| [`-f`](#file), [`--file stringArray`](#file) | Read source descriptor from file |
|
||||||
|
| [`-t`](#tag), [`--tag stringArray`](#tag) | Set reference for new image |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Imagetools contains commands for working with manifest lists in the registry.
|
||||||
|
These commands are useful for inspecting multi-platform build results.
|
||||||
|
|
||||||
|
Create creates a new manifest list based on source manifests. The source
|
||||||
|
manifests can be manifest lists or single platform distribution manifests and
|
||||||
|
must already exist in the registry where the new manifest is created. If only
|
||||||
|
one source is specified create performs a carbon copy.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### <a name="append"></a> Append new sources to an existing manifest list (--append)
|
||||||
|
|
||||||
|
Use the `--append` flag to append the new sources to an existing manifest list
|
||||||
|
in the destination.
|
||||||
|
|
||||||
|
### <a name="dry-run"></a> Show final image instead of pushing (--dry-run)
|
||||||
|
|
||||||
|
Use the `--dry-run` flag to not push the image, just show it.
|
||||||
|
|
||||||
|
### <a name="file"></a> Read source descriptor from a file (-f, --file)
|
||||||
|
|
||||||
|
```
|
||||||
|
-f FILE or --file FILE
|
||||||
|
```
|
||||||
|
|
||||||
|
Reads source from files. A source can be a manifest digest, manifest reference,
|
||||||
|
or a JSON of OCI descriptor object.
|
||||||
|
|
||||||
|
### <a name="tag"></a> Set reference for new image (-t, --tag)
|
||||||
|
|
||||||
|
```
|
||||||
|
-t IMAGE or --tag IMAGE
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the `-t` or `--tag` flag to set the name of the image to be created.
|
||||||
|
|
||||||
|
**Examples**
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx imagetools create --dry-run alpine@sha256:5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907 sha256:c4ba6347b0e4258ce6a6de2401619316f982b7bcc529f73d2a410d0097730204
|
||||||
|
|
||||||
|
$ docker buildx imagetools create -t tonistiigi/myapp -f image1 -f image2
|
||||||
|
```
|
@ -0,0 +1,47 @@
|
|||||||
|
# buildx imagetools inspect
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx imagetools inspect [OPTIONS] NAME
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Show details of image in the registry
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| [`--raw`](#raw) | Show original JSON manifest |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Show details of image in the registry.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx imagetools inspect alpine
|
||||||
|
|
||||||
|
Name: docker.io/library/alpine:latest
|
||||||
|
MediaType: application/vnd.docker.distribution.manifest.list.v2+json
|
||||||
|
Digest: sha256:28ef97b8686a0b5399129e9b763d5b7e5ff03576aa5580d6f4182a49c5fe1913
|
||||||
|
|
||||||
|
Manifests:
|
||||||
|
Name: docker.io/library/alpine:latest@sha256:5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907
|
||||||
|
MediaType: application/vnd.docker.distribution.manifest.v2+json
|
||||||
|
Platform: linux/amd64
|
||||||
|
|
||||||
|
Name: docker.io/library/alpine:latest@sha256:c4ba6347b0e4258ce6a6de2401619316f982b7bcc529f73d2a410d0097730204
|
||||||
|
MediaType: application/vnd.docker.distribution.manifest.v2+json
|
||||||
|
Platform: linux/arm/v6
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="raw"></a> Show original, unformatted JSON manifest (--raw)
|
||||||
|
|
||||||
|
Use the `--raw` option to print the original JSON bytes instead of the formatted
|
||||||
|
output.
|
@ -0,0 +1,58 @@
|
|||||||
|
# buildx inspect
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx inspect [NAME]
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Inspect current builder instance
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| [`--bootstrap`](#bootstrap) | Ensure builder has booted before inspecting |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Shows information about the current or specified builder.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Get information about a builder instance
|
||||||
|
|
||||||
|
By default, `inspect` shows information about the current builder. Specify the
|
||||||
|
name of the builder to inspect to get information about that builder.
|
||||||
|
The following example shows information about a builder instance named
|
||||||
|
`elated_tesla`:
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx inspect elated_tesla
|
||||||
|
|
||||||
|
Name: elated_tesla
|
||||||
|
Driver: docker-container
|
||||||
|
|
||||||
|
Nodes:
|
||||||
|
Name: elated_tesla0
|
||||||
|
Endpoint: unix:///var/run/docker.sock
|
||||||
|
Status: running
|
||||||
|
Platforms: linux/amd64
|
||||||
|
|
||||||
|
Name: elated_tesla1
|
||||||
|
Endpoint: ssh://ubuntu@1.2.3.4
|
||||||
|
Status: running
|
||||||
|
Platforms: linux/arm64, linux/arm/v7, linux/arm/v6
|
||||||
|
```
|
||||||
|
|
||||||
|
### <a name="bootstrap"></a> Ensure that the builder is running before inspecting (--bootstrap)
|
||||||
|
|
||||||
|
Use the `--bootstrap` option to ensures that the builder is running before
|
||||||
|
inspecting it. If the driver is `docker-container`, then `--bootstrap` starts
|
||||||
|
the buildkit container and waits until it is operational. Bootstrapping is
|
||||||
|
automatically done during build, it is thus not necessary. The same BuildKit
|
||||||
|
container is used during the lifetime of the associated builder node (as
|
||||||
|
displayed in `buildx ls`).
|
@ -0,0 +1,11 @@
|
|||||||
|
# buildx install
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx install
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Install buildx as a 'docker builder' alias
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
@ -0,0 +1,31 @@
|
|||||||
|
# buildx ls
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx ls
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
List builder instances
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Lists all builder instances and the nodes for each instance
|
||||||
|
|
||||||
|
**Example**
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx ls
|
||||||
|
|
||||||
|
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
|
||||||
|
elated_tesla * docker-container
|
||||||
|
elated_tesla0 unix:///var/run/docker.sock running linux/amd64
|
||||||
|
elated_tesla1 ssh://ubuntu@1.2.3.4 running linux/arm64, linux/arm/v7, linux/arm/v6
|
||||||
|
default docker
|
||||||
|
default default running linux/amd64
|
||||||
|
```
|
||||||
|
|
||||||
|
Each builder has one or more nodes associated with it. The current builder's
|
||||||
|
name is marked with a `*`.
|
@ -0,0 +1,23 @@
|
|||||||
|
# buildx prune
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx prune
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Remove build cache
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `-a`, `--all` | Remove all unused images, not just dangling ones |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| `--filter filter` | Provide filter values (e.g. 'until=24h') |
|
||||||
|
| `-f`, `--force` | Do not prompt for confirmation |
|
||||||
|
| `--keep-storage bytes` | Amount of disk space to keep for cache |
|
||||||
|
| `--verbose` | Provide a more verbose output |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
# buildx rm
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx rm [NAME]
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Remove a builder instance
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Removes the specified or current builder. It is a no-op attempting to remove the
|
||||||
|
default builder.
|
@ -0,0 +1,16 @@
|
|||||||
|
# buildx stop
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx stop [NAME]
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Stop builder instance
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Stops the specified or current builder. This will not prevent buildx build to
|
||||||
|
restart the builder. The implementation of stop depends on the driver.
|
@ -0,0 +1,11 @@
|
|||||||
|
# buildx uninstall
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx uninstall
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Uninstall the 'docker builder' alias
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
@ -0,0 +1,25 @@
|
|||||||
|
# buildx use
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx use [OPTIONS] NAME
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Set the current builder instance
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `--builder string` | Override the configured builder instance |
|
||||||
|
| `--default` | Set builder as default for current context |
|
||||||
|
| `--global` | Builder persists context changes |
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Switches the current builder instance. Build commands invoked after this command
|
||||||
|
will run on a specified builder. Alternatively, a context name can be used to
|
||||||
|
switch to the default builder of that context.
|
@ -0,0 +1,21 @@
|
|||||||
|
# buildx version
|
||||||
|
|
||||||
|
```
|
||||||
|
docker buildx version
|
||||||
|
```
|
||||||
|
|
||||||
|
<!---MARKER_GEN_START-->
|
||||||
|
Show buildx version information
|
||||||
|
|
||||||
|
|
||||||
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### View version information
|
||||||
|
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ docker buildx version
|
||||||
|
github.com/docker/buildx v0.5.1-docker 11057da37336192bfc57d81e02359ba7ba848e4a
|
||||||
|
```
|
@ -0,0 +1,29 @@
|
|||||||
|
# syntax = docker/dockerfile:1.2
|
||||||
|
|
||||||
|
FROM golang:1.16-alpine AS docsgen
|
||||||
|
WORKDIR /src
|
||||||
|
RUN --mount=target=. \
|
||||||
|
--mount=target=/root/.cache,type=cache \
|
||||||
|
go build -mod=vendor -o /out/docsgen ./docs/docsgen
|
||||||
|
|
||||||
|
FROM alpine AS gen
|
||||||
|
RUN apk add --no-cache rsync git
|
||||||
|
WORKDIR /src
|
||||||
|
COPY --from=docsgen /out/docsgen /usr/bin
|
||||||
|
RUN --mount=target=/context \
|
||||||
|
--mount=target=.,type=tmpfs,readwrite \
|
||||||
|
rsync -a /context/. . && \
|
||||||
|
docsgen && \
|
||||||
|
mkdir /out && cp -r docs/reference /out
|
||||||
|
|
||||||
|
FROM scratch AS update
|
||||||
|
COPY --from=gen /out /out
|
||||||
|
|
||||||
|
FROM gen AS validate
|
||||||
|
RUN --mount=target=/context \
|
||||||
|
--mount=target=.,type=tmpfs,readwrite \
|
||||||
|
rsync -a /context/. . && \
|
||||||
|
git add -A && \
|
||||||
|
rm -rf docs/reference/* && \
|
||||||
|
cp -rf /out/* ./docs/ && \
|
||||||
|
./hack/validate-docs check
|
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
. $(dirname $0)/util
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
output=$(mktemp -d -t buildx-output.XXXXXXXXXX)
|
||||||
|
|
||||||
|
buildxCmd build \
|
||||||
|
--target "update" \
|
||||||
|
--output "type=local,dest=$output" \
|
||||||
|
--file "./hack/dockerfiles/docs.Dockerfile" \
|
||||||
|
.
|
||||||
|
|
||||||
|
rm -rf ./docs/reference/*
|
||||||
|
cp -R "$output"/out/* ./docs/
|
||||||
|
rm -rf $output
|
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
case ${1:-} in
|
||||||
|
'')
|
||||||
|
. $(dirname $0)/util
|
||||||
|
buildxCmd build \
|
||||||
|
--target validate \
|
||||||
|
--file ./hack/dockerfiles/docs.Dockerfile \
|
||||||
|
.
|
||||||
|
;;
|
||||||
|
check)
|
||||||
|
status="$(git status --porcelain -- docs/reference 2>/dev/null)"
|
||||||
|
diffs=$(echo "$status" | grep -v '^[RAD] ' || true)
|
||||||
|
if [ "$diffs" ]; then
|
||||||
|
{
|
||||||
|
set +x
|
||||||
|
echo 'The result of ./hack/update-docs differs'
|
||||||
|
echo
|
||||||
|
echo "$diffs"
|
||||||
|
echo
|
||||||
|
echo 'Please vendor your package with ./hack/update-docs'
|
||||||
|
echo
|
||||||
|
} >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo 'Congratulations! All docs changes are done the right way.'
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue