11009 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
adb0abaec5
add top-level "docker bake" command as alias for "docker buildx bake"
The [`docker buildx bake`][1] command has reached GA; this patch adds
a top-level `docker bake` command as alias for `docker buildx bake` to
improve discoverability and make it more convenient to use.

With this patch:

    docker --help

    Usage:  docker [OPTIONS] COMMAND

    A self-sufficient runtime for containers

    Common Commands:
      run         Create and run a new container from an image
      exec        Execute a command in a running container
      ps          List containers
      build       Build an image from a Dockerfile
      bake        Build from a file
      pull        Download an image from a registry
      push        Upload an image to a registry
      images      List images
    ...

The command is hidden if buildx is not installed;

    docker --help
    Usage:  docker [OPTIONS] COMMAND

    A self-sufficient runtime for containers

    Common Commands:
      run         Create and run a new container from an image
      exec        Execute a command in a running container
      ps          List containers
      build       Build an image from a Dockerfile
      pull        Download an image from a registry
      push        Upload an image to a registry
      images      List images
    ...

We can do some tweaking after this; currently it show an error
in situations where buildx is missing. We don't account for
"DOCKER_BUILDKIT=0", because this is a new feature that requires
buildx, and cannot be "disabled";

buildx missing;

    docker bake
    ERROR: bake requires the buildx component but it is missing or broken.
           Install the buildx component to use bake:
           https://docs.docker.com/go/buildx/

BuildKit disabled:

    DOCKER_BUILDKIT=0 docker bake
    ERROR: bake requires the buildx component but it is missing or broken.
           Install the buildx component to use bake:
           https://docs.docker.com/go/buildx/

[1]: https://www.docker.com/blog/ga-launch-docker-bake/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 16:28:47 +02:00
Paweł Gronowski
e937b52210
Merge pull request #5953 from thaJeztah/opts_remove_deprecated
opts: remove deprecated PortOpt, ConfigOpt, SecretOpt aliases
2025-04-11 14:13:10 +00:00
Sebastiaan van Stijn
6aa93d1f40
Merge pull request #5952 from thaJeztah/move_prompt_utils_step1
cli/command: move prompt utilities to separate package
2025-04-11 16:11:12 +02:00
Sebastiaan van Stijn
a85062bcdc
Merge pull request #5934 from vvoland/inspect-platform
image/inspect: Add --platform flag
2025-04-11 16:08:46 +02:00
Paweł Gronowski
0d9d187f31
image/inspect: Add --platform flag
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 15:53:41 +02:00
Sebastiaan van Stijn
559c0121c8
Merge pull request #6002 from vvoland/vendor-docker
vendor: github.com/docker/docker v28.1.0-dev (250792c1a540)
2025-04-11 15:47:59 +02:00
Paweł Gronowski
ec9e729f76
vendor: github.com/docker/docker v28.1.0-dev (250792c1a540)
full diff: 511cd1c0a7...250792c1a5

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 15:23:24 +02:00
Paweł Gronowski
07b203e2f2
Merge pull request #5924 from thaJeztah/hide_untagged
docker images --tree: hide both untagged and dangling images by default
2025-04-11 13:14:59 +00:00
Sebastiaan van Stijn
f18e239a53
docker images --tree: hide both untagged and dangling images by default
Before this patch, `docker image ls` / `docker image ls` would always
show untagged images, but hide "dangling" images (which effectively
only were produced by the legacy builder) unless `-a` / `--all` was
used. This often resulted in many `<none>:<none>` or `<untagged>` images
to be shown, which had little value to interact with, other than to
garbage collect (`docker system prune`).

In future, we want to take more advantage of containerd's garbage-collecting
features (removing unused images automatically), and this UX change is
a stepping stone toward that.

For now, this patch only changes the behavior for `docker image ls --tree`,
but we should make this the same for "non" --tree as well.

This patch:

- changes `docker image ls` to hide both "untagged" and "dangling" images
  by default.
- changes the behavior of `--all` on the client side to make them visible

The API response remains the same for now, but this is something we can
consider changing in future (possibly more granular than a single boolean).

Before this patch;

    docker image ls --tree
                                                                           i Info →   U  In Use

    IMAGE                                      ID             DISK USAGE   CONTENT SIZE   EXTRA
    docker:cli                                 28fb556c1ea1        276MB         69.8MB
    ├─ linux/amd64                             828f4f57525d           0B             0B
    ├─ linux/arm/v6                            563c0b58e54b           0B             0B
    ├─ linux/arm/v7                            6045d4846c59           0B             0B
    └─ linux/arm64/v8                          11e8dfd68841        276MB         69.8MB

    alpine:latest                              a8560b36e8b8       12.8MB         3.99MB    U
    ├─ linux/amd64                             1c4eef651f65           0B             0B
    ├─ linux/arm/v6                            903bfe2ae994           0B             0B
    ├─ linux/arm/v7                            9c2d245b3c01           0B             0B
    ├─ linux/arm64/v8                          757d680068d7       12.8MB         3.99MB    U
    ├─ linux/386                               2436f2b3b7d2           0B             0B
    ├─ linux/ppc64le                           9ed53fd3b831           0B             0B
    ├─ linux/riscv64                           1de5eb4a9a67           0B             0B
    └─ linux/s390x                             fe0dcdd1f783           0B             0B

    <untagged>                                 c6c1bcb0fd8d       12.8MB         3.99MB
    └─ linux/arm64                             cb171c618ae8       12.8MB         3.99MB

    <untagged>                                 7361ef970703       12.8MB         3.99MB
    └─ linux/arm64                             07033f43e44a       12.8MB         3.99MB

    <untagged>                                 0c62c63b81ec       12.8MB         3.99MB
    └─ linux/arm64                             94742272117f       12.8MB         3.99MB

    <untagged>                                 91dd947eebd0       12.8MB         3.99MB
    └─ linux/arm64                             ee55d203e26f       12.8MB         3.99MB

    <untagged>                                 382d9f57e8d8       12.8MB         3.99MB
    └─ linux/arm64                             5256d47804e3       12.8MB         3.99MB

    <untagged>                                 56fa17d2a7e7       12.8MB         3.99MB
    ├─ linux/amd64                             483f502c0e6a           0B             0B
    ├─ linux/arm/v6                            c79529000bdf           0B             0B
    ├─ linux/arm/v7                            cc455d4b2c47           0B             0B
    ├─ linux/arm64/v8                          508c1b94e1d2       12.8MB         3.99MB
    ├─ linux/386                               f32403957113           0B             0B
    ├─ linux/ppc64le                           23dbce23b88f           0B             0B
    ├─ linux/riscv64                           f9d2da150cee           0B             0B
    └─ linux/s390x                             6bb03952a007           0B             0B

After this patch

    docker image ls --tree
                                                                           i Info →   U  In Use

    IMAGE                                      ID             DISK USAGE   CONTENT SIZE   EXTRA
    docker:cli                                 28fb556c1ea1        276MB         69.8MB
    ├─ linux/amd64                             828f4f57525d           0B             0B
    ├─ linux/arm/v6                            563c0b58e54b           0B             0B
    ├─ linux/arm/v7                            6045d4846c59           0B             0B
    └─ linux/arm64/v8                          11e8dfd68841        276MB         69.8MB

    alpine:latest                              a8560b36e8b8       12.8MB         3.99MB    U
    ├─ linux/amd64                             1c4eef651f65           0B             0B
    ├─ linux/arm/v6                            903bfe2ae994           0B             0B
    ├─ linux/arm/v7                            9c2d245b3c01           0B             0B
    ├─ linux/arm64/v8                          757d680068d7       12.8MB         3.99MB    U
    ├─ linux/386                               2436f2b3b7d2           0B             0B
    ├─ linux/ppc64le                           9ed53fd3b831           0B             0B
    ├─ linux/riscv64                           1de5eb4a9a67           0B             0B
    └─ linux/s390x                             fe0dcdd1f783           0B             0B

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 14:58:23 +02:00
Sebastiaan van Stijn
c718d3f13c
Merge pull request #6000 from vvoland/image-tree-totalcontent
cli/command/image: Fix total content size calculation in image tree
2025-04-11 13:45:35 +02:00
Paweł Gronowski
1a950db5ce
cli/command/image: Fix total content size calculation in image tree
Before this patch, image total content size would only include
container images content size.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 13:30:20 +02:00
Sebastiaan van Stijn
e2865628ae
Merge pull request #5983 from thaJeztah/fix_context_non_default
cli/command: DockerCli.Initialize: make sure context-store config is set
2025-04-11 12:46:15 +02:00
Sebastiaan van Stijn
e578f156c0
Merge pull request #5998 from thaJeztah/lazy_regexp
use lazyregexp to compile regexes on first use
2025-04-11 12:29:53 +02:00
Sebastiaan van Stijn
b74b7b3c40
internal/prompt: TestConfirm: don't use un-keyed structs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 12:23:24 +02:00
Sebastiaan van Stijn
ecde8c38a5
internal/prompt: skip fmt.Printf and use writer directly
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 12:23:21 +02:00
Sebastiaan van Stijn
b37d84fd10
cli/command: move prompt utilities to separate package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 12:23:16 +02:00
Sebastiaan van Stijn
af85e1e2f7
cli/command: implement ErrPromptTerminated without errdefs package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 12:15:11 +02:00
Sebastiaan van Stijn
8633197105
Merge pull request #5914 from thaJeztah/use_atomicwriter
cli/command: deprecate CopyToFile and reimplement with atomicwriter
2025-04-11 12:10:46 +02:00
Sebastiaan van Stijn
94afbc1116
Merge pull request #5999 from thaJeztah/bump_engine
vendor: github.com/docker/docker 511cd1c0a736 (master, v28.x-dev)
2025-04-11 12:09:28 +02:00
Sebastiaan van Stijn
4530417f6b
vendor: github.com/docker/docker 511cd1c0a736 (master, v28.x-dev)
full diff: 185651d26b...511cd1c0a7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 22:03:48 +02:00
Sebastiaan van Stijn
23d7346f75
Merge pull request #5977 from thaJeztah/deprecate_config_experimental
cli/config/configfile: deprecate ConfigFile.Experimental field
2025-04-10 14:36:11 +02:00
Sebastiaan van Stijn
4c820d3ac0
golangci-lint: add forbidigo rules to prevent regex.MustCompile
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:27 +02:00
Sebastiaan van Stijn
ced66f22d6
cli/compose/template: use lazyregexp to compile regexes on first use
This package needed an (internal) interface to abstract the lazy-regexp.
For this, I split the implementation from the exported implementation; this
also revealed that some functions are not used (at least not in our code
base), and we could consider deprecating these.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:26 +02:00
Sebastiaan van Stijn
0b0fc106dc
cli/compose/template: rename vars that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:26 +02:00
Sebastiaan van Stijn
56c2fa6c0e
e2e/cli-plugins: use regexp.Compile to prevent panic in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:26 +02:00
Sebastiaan van Stijn
1ed3859879
cli-plugins/manager: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:26 +02:00
Sebastiaan van Stijn
7fde1f799f
cli/context/store: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:25 +02:00
Sebastiaan van Stijn
d5a8cd4093
cli/command/trust: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:25 +02:00
Sebastiaan van Stijn
01d8642c7e
cli/command/system: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:25 +02:00
Sebastiaan van Stijn
a16c3a49c8
cli/command/image: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:25 +02:00
Sebastiaan van Stijn
d76057210a
cli/command/container: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:25 +02:00
Sebastiaan van Stijn
9a849ba00c
opts: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:24 +02:00
Sebastiaan van Stijn
481e6f1477
implement lazyregexp package
Based on the "lazyregexp" package in golang.org/x/mod;
https://cs.opensource.google/go/x/mod/+/refs/tags/v0.19.0:internal/lazyregexp/lazyre.go;l=66-78

This package allows defining regular expressions that should not be
compiled until used, but still providing validation to prevent
invalid regular expressions from producing a panic at runtime.

This is largely a copy of the package from golang.org/x/mod,
with FindAllStringSubmatch and ReplaceAllStringFunc added

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:22:24 +02:00
Paweł Gronowski
bcd9c885e3
Merge pull request #5997 from thaJeztah/fastpath_needs_serverinfo
cli/command/system: needsServerInfo: add fast-paths
2025-04-10 09:24:06 +00:00
Paweł Gronowski
e587e8a269
Merge pull request #5996 from thaJeztah/bump_x_deps
vendor: update golang.org/x/.. dependencies
2025-04-10 09:23:17 +00:00
Sebastiaan van Stijn
932574363f
cli/command/system: needsServerInfo: add fast-paths
We can return early without executing the regular expression or evaluating
the template for `--format=json` or `--format='{{json .}}'`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 10:50:04 +02:00
Sebastiaan van Stijn
ac375caa87
Merge pull request #5918 from Benehiko/info-exit-code
system/info: failure to connect to docker socket should propagate error
2025-04-10 10:31:05 +02:00
Sebastiaan van Stijn
7cc6b8ebf4
cli/command: deprecate CopyToFile and reimplement with atomicwriter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 09:46:06 +02:00
Sebastiaan van Stijn
b8bcf6f5ad
container export: implement file-write with atomicwriter
Same functionality, but implemented with atomicwriter. There's a slight
difference in error-messages produced (but can be adjusted if we want).

Before:

    docker container export -o ./no/such/foo mycontainer
    failed to export container: invalid output path: directory "no/such" does not exist

    docker container export -o /no/permissions mycontainer
    failed to export container: stat /no/permissions: permission denied

After:

    docker container export -o ./no/such/foo mycontainer
    failed to export container: invalid file path: stat no/such: no such file or directory

    docker container export -o /no/permissions mycontainer
    failed to export container: failed to stat output path: lstat /no/permissions: permission denied

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 09:46:06 +02:00
Sebastiaan van Stijn
d47d2338b7
image save: implement file-write with atomicwriter
Same functionality, but implemented with atomicwriter. There's a slight
difference in error-messages produced (but can be adjusted if we want).

Before:

    docker image save -o ./no/such/foo busybox:latest
    failed to save image: invalid output path: directory "no/such" does not exist

    docker image save -o /no/permissions busybox:latest
    failed to save image: stat /no/permissions: permission denied

After:

    docker image save -o ./no/such/foo busybox:latest
    failed to save image: invalid file path: stat no/such: no such file or directory

    docker image save -o /no/permissions busybox:latest
    failed to save image: failed to stat output path: lstat /no/permissions: permission denied

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 09:46:05 +02:00
Sebastiaan van Stijn
410c0baadd
Merge pull request #5992 from thaJeztah/migrate_archive
migrate to use github.com/moby/go-archive
2025-04-10 09:10:41 +02:00
Sebastiaan van Stijn
d83a1b777c
vendor: golang.org/x/net v0.39.0
full diff: https://github.com/golang/net/compare/v0.36.0...v0.39.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 00:01:30 +02:00
Sebastiaan van Stijn
b515831508
vendor: golang.org/x/crypto v0.37.0
full diff: https://github.com/golang/crypto/compare/v0.35.0...v0.37.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 00:00:46 +02:00
Sebastiaan van Stijn
2d3a81642a
vendor: golang.org/x/text v0.24.0
no changes in vendored files

full diff: https://github.com/golang/text/compare/v0.22.0...v0.24.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 23:59:55 +02:00
Sebastiaan van Stijn
69d903e706
vendor: golang.org/x/sync v0.13.0
full diff: https://github.com/golang/sync/compare/v0.11.0...v0.13.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 23:59:03 +02:00
Sebastiaan van Stijn
e0fa0596a7
vendor: golang.org/x/time v0.11.0
full diff: https://github.com/golang/time/compare/v0.6.0...v0.11.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 23:58:09 +02:00
Sebastiaan van Stijn
a91d194d7f
vendor: golang.org/x/sys v0.32.0
full diff: https://github.com/golang/sys/compare/v0.31.0...v0.32.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 23:57:22 +02:00
Sebastiaan van Stijn
342a01a9ff
migrate to use github.com/moby/go-archive
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 13:18:58 +02:00
Sebastiaan van Stijn
6714b50288
Merge pull request #5921 from thaJeztah/bump_engine
vendor: github.com/docker/docker 185651d26bc6 (master, v28.0-dev)
2025-04-09 13:12:32 +02:00
Sebastiaan van Stijn
2bf317ad5f
vendor: github.com/docker/docker 185651d26bc6 (master, v28.0-dev)
full diff: https://github.com/moby/moby/compare/v28.0.4...185651d26bc6281b199a5b7ff1942b53e4f17b96

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

vendor: moby with atomicwriter

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 19:20:39 +02:00