Commit Graph

4125 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
91ba210bc8 Merge pull request #49666 from thaJeztah/legacy_errors
api, client: produce human-readable errors for unsupported API versions (< v1.24)
2025-04-10 12:08:56 +02:00
Sebastiaan van Stijn
bcbcbb73fa Merge pull request #49743 from dmcgowan/update-archive-to-go-archive
Update archive to use github.com/moby/go-archive
2025-04-09 11:51:14 +02:00
Albin Kerouanton
489cd7edfc api, daemon, libnet: add a 'trigger' baggage member
Add an OTel span processor copying the 'trigger' baggage member
propagated through contexts to all children spans. It's used to identify
what triggered a trace / span (API call, libnet init, etc...)

All code paths that call libnet's `NewNetwork` set this baggage member
with a unique value.

For instance, this can be used to distinguish bridge's `createNetwork`
spans triggered by daemon / libnet initialization from custom network
creation triggerd by an API call.

Two util functions are added to wrap `baggage.New` and
`baggage.NewMemberRaw` to make it easier to deal with baggage and
members by panicking on error. These should not be used with dynamic
values.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:45:33 +02:00
Albin Kerouanton
78be7ebad7 libnet/d/bridge: trace createNetwork
Plumb context from the API down to libnet driver method `CreateNetwork`,
and add an OTel span to the bridge driver's `createNetwork` method.
Include a few attributes describing the network configuration (e.g.
IPv4/IPv6, ICC, internal and MTU).

A new util function, `RecordStatus`, is added to the `otelutil` package
to easily record any error, and update the span status accordingly.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:45:33 +02:00
Derek McGowan
d0154d3e59 Update to use github.com/moby/go-archive
Update use of idtools to moby/user for archive and other deprecated uses

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 17:35:05 -07:00
Sebastiaan van Stijn
7d9c50db2b api: /info: omit non-distributable-artifacts fields for API >= 1.49
- registry.ServiceConfig: add a "ExtraFields" for outputting deprecated
  fields.
- remove uses of AllowNondistributableArtifactsCIDRs and AllowNondistributableArtifactsHostnames

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 19:12:09 +02:00
Rob Murray
a0a86d0982 Add Info.FirewallBackend
Report FirewallBackend in "docker info".

It's currently "iptables" or "iptables+firewalld" on Linux, and
omitted on Windows.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-07 16:56:49 +01:00
Paweł Gronowski
59169d0f97 image/inspect: Add platform selection
`GET /image/{name}/json` now supports `platform` parameter allowing to
specify which platform variant of a multi-platform image to inspect.

For servers that do not use containerd image store integration, this
option will cause an error if the requested platform doesn't match the
image's actual platform

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-03 13:57:51 +02:00
Rob Murray
b5b6e1b24c Merge pull request #49726 from kristianheljas/image-get-platform-parameter
Add missing platform parameter to ImageGet api docs and add it under Image tag
2025-04-02 19:26:01 +01:00
Kristian Heljas
749e35cf5e Move ImageGet api docs under Image tag
Signed-off-by: Kristian Heljas <kristian@kristian.ee>
2025-04-01 16:06:17 +03:00
Kristian Heljas
094df015b1 Add missing platform parameter to ImageGetAll api docs
Signed-off-by: Kristian Heljas <kristian@kristian.ee>
2025-04-01 16:06:03 +03:00
Paweł Gronowski
4390ab275a api: bump API version to 1.49
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-31 14:09:39 +02:00
Sebastiaan van Stijn
d0b4bdbd25 api/router: postContainersAttach, wsContainersAttach: minor cleanups
- remove intermediate variables that were only used once
- move variables closer to where used

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:29:28 +01:00
Sebastiaan van Stijn
230f178f8b api: return plain-text errors for deprecated API versions
Docker 25.0 (08e4e88482) deprecated API versions
older than v1.24, and support was removed in Docker 26.0.

As part of this deprecation, support for plain-text errors was also removed
in commit ffd877f948.

So while we no longer support API versions older 1.24 [api.MinSupportedAPIVersion],
a client may try to connect using an older version and expect a plain-text error
instead of a JSON error. This would result in an "API version too old" error
formatted in JSON being printed as-is.

    DOCKER_API_VERSION=v1.10 docker info --format '{{.ID}}'
    Error response from daemon: {"message":"client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}

    curl --unix-socket /var/run/docker.sock http://localhost/v1.10/info
    {"message":"client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}

Note that this was only a problem for old API versions; unsupported API versions
that were higher than the maximum version were already handled as JSON;

    DOCKER_API_VERSION=v1.99 docker info --format '{{.ID}}'
    Error response from daemon: client version 1.99 is too new. Maximum supported API version is 1.48

    curl --unix-socket /var/run/docker.sock http://localhost/v1.99/info
    {"message":"client version 1.99 is too new. Maximum supported API version is 1.48"}

Let's be nice, and return errors in plain-text to provide a more readable error
to help the user understand the API version they're using is no longer supported.

With this patch applied:

    DOCKER_API_VERSION=v1.10 docker info --format '{{.ID}}'
    Error response from daemon: client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

    curl --unix-socket /var/run/docker.sock http://localhost/v1.10/info
    client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 20:25:05 +01:00
Sebastiaan van Stijn
df0cefcc95 api/swagger: improve doc for Secret and Config data fields
Document the size constraints as defined by swarm;

- 500KB ([MaxSecretSize]) for secrets
- 1000KB ([MaxConfigSize]) for configs

[MaxSecretSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/api/validation#MaxSecretSize
[MaxConfigSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/manager/controlapi#MaxConfigSize

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 12:39:42 +01:00
Sebastiaan van Stijn
f2d53142b0 api/types/swarm: document Secret and Config data fields
Document the size constraints as defined by swarm;

- 500KB ([MaxSecretSize]) for secrets
- 1000KB ([MaxConfigSize]) for configs

[MaxSecretSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/api/validation#MaxSecretSize
[MaxConfigSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/manager/controlapi#MaxConfigSize

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 12:34:18 +01:00
Sebastiaan van Stijn
c359cc6829 api/types/registry: fix naked returns
api/types/registry/registry.go:60:2: naked return in func `UnmarshalJSON` with 9 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:16 +01:00
Sebastiaan van Stijn
b1c008c007 api/server/router/build: fix naked returns
api/server/router/build/build_routes.go:359:2: naked return in func `Write` with 5 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:16 +01:00
Sebastiaan van Stijn
5eab938af8 Merge pull request #49477 from thaJeztah/swagger_container_examples
api/swagger: remove custom example from /containers/json endpoint
2025-02-18 13:33:06 +01:00
Sebastiaan van Stijn
322eddfb41 api/swagger: remove custom example from /containers/{id}/json endpoint
Create a ContainerInspectResponse definition and Use the example fields
as defined in the definition; add additional examples in that definition
where missing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 11:58:10 +01:00
Sebastiaan van Stijn
60539d0956 api/swagger: remove custom example from /containers/json endpoint
Use the example fields as defined in the ContainerSummary definition,
and add additional examples in that definition where missing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 11:45:57 +01:00
Sebastiaan van Stijn
7b6c3ebe7b api/swagger: inline Exec example values
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-17 21:55:14 +01:00
Sebastiaan van Stijn
6ee1558852 Merge pull request #49417 from thaJeztah/fix_linting_step1
Fix linting issues to allow enabling more linters
2025-02-13 23:58:24 +01:00
Sebastiaan van Stijn
3b8eb1ec2a Merge pull request #49407 from jsternberg/containers-platform-json
API: add Platform (OS and Architecture) to /containers/json
2025-02-13 23:35:55 +01:00
Jonathan A. Sternberg
927e07e46e API: add Platform (OS and Architecture) to /containers/json
Adds platform information to containers (for `docker ps`).

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-02-13 14:52:21 -06:00
Laurent Goderre
3e51818c5c Add ability to return warnings from host config
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-12 09:48:23 -05:00
Sebastiaan van Stijn
56a6383883 api: deprecation of "error" and "progress" fields in streaming responses
- error (ErrorMessage) was deprecated in 3043c26419
  which was part of docker v0.6.0 / API v1.4
- progress (ProgressMessage) was deprecated in 597e0e69b4
  which was part of docker v0.7.1 / API v1.8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 16:29:10 +01:00
Sebastiaan van Stijn
b99b5422b0 api/types: deprecate IDResponse
Deprecate `api/type.IDResponse` in favor of `container.CommitResponse` and
`container.ExecCreateResponse`, which are currently an alias, but may become
distinct types in a future release. This type  will be removed in the next
release.

updates 0df3a0047a
updates 9a20edf7b6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 13:02:41 +01:00
Sebastiaan van Stijn
6856bdd5a6 Merge pull request #49444 from thaJeztah/commit_and_exect_response
api/types/container: introduce CommitResponse, ExecCreateResponse types
2025-02-11 12:53:09 +01:00
Sebastiaan van Stijn
9a20edf7b6 api/types/container: introduce ExecCreateResponse type
Introduce a container.ExecCreateResponse type as alias for IDResponse to allow
consumers to use ContainerCommit without having to import the "types" package,
and allows us to differentiate the response for container commit separate from
other endpoints currently using IDResponse.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 21:14:11 +01:00
Sebastiaan van Stijn
0df3a0047a api/types/container: introduce CommitResponse type
Move api/types.IDResponse to a "common" package (to prevent cyclic import
issues), and introduce a container.CommitResponse type as alias. This allows
consumers to use ContainerCommit without having to import the "types" package,
and allows us to differentiate the response for container commit separate from
other endpoints currently using IDResponse.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 21:14:03 +01:00
Sebastiaan van Stijn
be1ac5d8e5 api/types/container: rename ContainerTopOKBody to TopResponse
Deprecate ContainerTopOKBody, but keep an alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 18:58:31 +01:00
Sebastiaan van Stijn
f4dc38cd36 api/types/container: rename ContainerUpdateOKBody to UpdateResponse
Deprecate ContainerUpdateOKBody, but keep an alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 18:35:35 +01:00
Sebastiaan van Stijn
7dbceec8aa api/server/router/volume: fix unhandled errors in tests (errchkjson)
Also fixing some minor other linting issues.

    api/server/router/volume/volume_routes_test.go:193:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        e.Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:231:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:260:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:292:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:339:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeUpdate)
        ^
    api/server/router/volume/volume_routes_test.go:366:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeUpdate)
        ^
    api/server/router/volume/volume_routes_test.go:396:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeUpdate)
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Paweł Gronowski
3d37537f75 c8d/inspect: Add Manifests field
Add `Manifests` field to image inspect (`/images/{name}/json`) response.
This is the same as in `/images/json`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 13:30:24 +01:00
Paweł Gronowski
02563f2805 Merge pull request #48798 from LaurentGoderre/implement-30449-image-mount
Implement mount from image
2025-02-05 18:04:22 +00:00
Laurent Goderre
90aea3b85f Add image subpath mounting functionality
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-04 21:32:04 -05:00
Paweł Gronowski
72b835151a Merge pull request #48720 from jsternberg/buildkit-gc-options
builder: wire up new gc types for buildkit prune functionality
2025-02-03 16:55:46 +00:00
Laurent Goderre
8c58934106 Implement mount from image
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-01-31 10:34:27 -05:00
Laurent Goderre
c935a4609d Fix typo in API docs
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-01-30 16:57:43 -05:00
Jonathan A. Sternberg
8e529682af builder: wire up new gc types for buildkit prune functionality
This wires up the new gc types that buildkit exposes in version 0.17.
The previous flag, `KeepBytes`, was renamed to `ReservedBytes` and two
new options, `MaxUsed` and `MinFree` were added.

`MaxUsed` corresponds to the maximum amount of space that buildkit will
use for the build cache and `MinFree` amount of free disk space for the
system to prevent the cache from using that space. This allows greater
configuration of the cache storage usage when used in situations where
docker is not the only service on the system using disk space.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-01-30 09:54:12 -06:00
Sebastiaan van Stijn
9b5a51a881 api/types/container: remove use of errdefs package in test
It was the only use of errdefs inside api/types, which is the package
that's imported by external users.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-29 12:36:40 +01:00
Sebastiaan van Stijn
3f354e8c1b api/types/registry: use stdlib errors package
It was the only use of github.com/pkg/errors inside api/types,
which is the package that's imported by external users.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-29 11:51:29 +01:00
Rob Murray
6bb69a21bf EnableIPv4:false is no longer --experimental
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 18:56:41 +00:00
Paweł Gronowski
96419cb52a Merge pull request #49266 from dvdksn/fromimage-tag-clarification
docs: clarify that tag or digest in fromImage is ignored
2025-01-21 10:35:55 +01:00
David Karlsson
bf7a87a15a docs: clarify fromImage vs tag behavior in ImageCreate
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2025-01-20 09:54:52 +01:00
Sebastiaan van Stijn
e8c6e7ceb0 build: don't print warning when connection was terminated
A terminated connection is not an error on the daemon-side, and expected
if the client disconnects. This patch detects if the error is because of
a broken pipe, and skips the warning in that case.

Before this patch:

    WARN[2025-01-18T12:38:04.115298341Z] could not write error response: write unix /var/run/docker.sock->@: write: broken pipe

After this patch, no warning is logged. This patch also changes the log
format to use structured logs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-18 16:24:54 +01:00
Sebastiaan van Stijn
81a2acdd23 Merge pull request #48696 from thaJeztah/build_log_cancelled
build: log when build is cancelled
2025-01-18 16:20:38 +01:00
Shaun Thompson
d9c2474d6a Merge pull request #49286 from thaJeztah/swagger_stats
api: swagger: document StatsResponse
2025-01-17 11:59:45 -05:00
Sebastiaan van Stijn
58de8c7dec Merge pull request #48740 from thaJeztah/fix_debug_logs
api/server/middleware: log before, not after the request
2025-01-17 16:59:05 +01:00