21 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
6a2a1dd6cf api/types/container: StatsResponse: add OSType field
Adds a per-stats OSType field to allow handle the platform-specific fields.
Before this change, the client had to get the OSType field from the server's
API response header and copy it to each record.

Older daemon versions don't have this field, so the client still needs to
handle fallbacks.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 16:39:32 +01:00
Sebastiaan van Stijn
7439f09cd2 daemon: Daemon.stats: fill-in container ID and Name when collecting
Propagate these fields when collecting the data, instead of patching the
result inside the router.

This also fixes a bug where the ID and Name fields were not set when using
one-shot.

Before this patch, the "id" and "name" fields were not set in one-shot mode:

    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false' | jq .id
    "125d7f3df7919c33195fa4ec0636c27cdbe6d9b14339867d2920900565bcaf7e"
    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false' | jq .name
    "/foo"

    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .id
    null
    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .name
    null

With this patch, both are set:

    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .id
    "125d7f3df7919c33195fa4ec0636c27cdbe6d9b14339867d2920900565bcaf7e"
    curl -s --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/foo/stats?stream=false&one-shot=true' | jq .name
    "/foo"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 10:55:01 +01:00
Derek McGowan
f74e5d48b3 Create github.com/moby/moby/v2 module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-31 10:13:29 -07:00
Derek McGowan
8042010175 Move internal/platform to daemon/internal/platform
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-24 12:14:46 -07:00
Derek McGowan
afd6487b2e Create github.com/moby/moby/api module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-21 09:30:05 -07:00
Derek McGowan
5419eb1efc Move container to daemon/container
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 14:27:21 -07:00
Sebastiaan van Stijn
5318877858 daemon: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:13 +02:00
Matthieu MOREL
55da8ea276 daemon: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:38:39 +00:00
Sebastiaan van Stijn
ca06b222e3 api/types/container: merge Stats and StatsResponse
The StatsResponse type  was a compatibility-wrapper introduced in
d3379946ec to differentiate responses
for  API < 1.21 and API >= 1.21. API versions lower than 1.24 are
deprecated, and we can merge these types again.

The Stats type was not used directly, but deprecating it, and
making it an alias for StatsResponse, which provides a superset
of its fields.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 19:47:40 +01:00
Sebastiaan van Stijn
b034dc41a2 deprecate pkg/platform and move internal
Functions in this package are only used internally in the daemon for
the `/info` endpoint (Architecture), and as part of `stats` (NumProcs).

I was not able to find external consumers, but deprecating the package
first, so that we can remove / dismantle the package in a follow-up.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 15:05:56 +01:00
Sebastiaan van Stijn
0a4277abf4 api/types: move stats-types to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 10:21:42 +02:00
Xinfeng Liu
95aea39348 Make one-shot stats faster
This commit moves one-shot stats processing out of the publishing
channels, i.e. collect stats directly.

Also changes the method of getSystemCPUUsage() on Linux to return
number of online CPUs also.

Signed-off-by: Xinfeng Liu <XinfengLiu@icloud.com>
2023-09-27 14:10:23 +08:00
Sebastiaan van Stijn
f691b13450 daemon: move code related to stats together
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-08 19:00:01 +02:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
John Howard
340e5233b2 Windows: stats support
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-09-16 11:56:15 -07:00
Tonis Tiigi
9c4570a958 Replace execdrivers with containerd implementation
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-03-18 13:38:32 -07:00
David Calavera
907407d0b2 Modify import paths to point to the new engine-api package.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-01-06 19:48:59 -05:00
Hu Keping
d3379946ec Refactor the statistics of network in docker stats
For now docker stats will sum the rxbytes, txbytes, etc. of all
the interfaces.

It is OK for the output of CLI `docker stats` but not good for
the API response, especially when the container is in sereval
subnets.

It's better to leave these origianl data to user.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2015-09-15 15:40:34 +08:00
Alexander Morozov
c86189d554 Update libcontainer
Replaced github.com/docker/libcontainer with
github.com/opencontainers/runc/libcontaier.
Also I moved AppArmor profile generation to docker.

Main idea of this update is to fix mounting cgroups inside containers.
After updating docker on CI we can even remove dind.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-07-16 16:02:26 -07:00
Brian Goff
855a056af7 Fixes content-type/length for stats stream=false
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-06-12 13:06:06 -04:00
John Howard
48f1cb4ebe Windows: refactor stats
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-05-20 09:08:45 -07:00