Skip to content

daemon/containerd: pass custom metaHeaders to resolver#51024

Merged
vvoland merged 1 commit intomoby:masterfrom
thaJeztah:custom_metaheaders
Sep 25, 2025
Merged

daemon/containerd: pass custom metaHeaders to resolver#51024
vvoland merged 1 commit intomoby:masterfrom
thaJeztah:custom_metaheaders

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Sep 23, 2025

Similar to how distribution.newRepository in the legacy distribution code passes the (custom) http-headers. User-Agent is always set, and can't be overridden, so we apply it after setting the custom headers.

Before this patch:

docker run --rm -d --name debugger -p 127.0.0.1:5001:8080 mendhak/http-https-echo
DOCKER_CUSTOM_HEADERS=X-Meta-Hello=thaJeztah docker pull localhost:5001/myimage:latest
docker logs debugger
...
"headers": {
    "host": "localhost:5001",
    "user-agent": "docker/dev go/go1.24.7 git-commit/8e89fe7e8cbb3048f640846590175cbae4719b25 kernel/6.10.14-linuxkit os/linux arch/arm64 containerd-client/2.1.4+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/28.3.2 \\(linux\\))",
    "accept": "application/json, */*",
    "accept-encoding": "zstd;q=1.0, gzip;q=0.8, deflate;q=0.5",
    "baggage": "trigger=api"
},

With this patch:

docker run --rm -d --name debugger -p 127.0.0.1:5001:8080 mendhak/http-https-echo
DOCKER_CUSTOM_HEADERS=X-Meta-Hello=thaJeztah docker pull localhost:5001/myimage:latest
docker logs debugger
...
"headers": {
    "host": "localhost:5001",
    "user-agent": "docker/dev go/go1.24.7 git-commit/8e89fe7e8cbb3048f640846590175cbae4719b25 kernel/6.10.14-linuxkit os/linux arch/arm64 containerd-client/2.1.4+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/28.3.2 \\(linux\\))",
    "accept": "application/json, */*",
    "accept-encoding": "zstd;q=1.0, gzip;q=0.8, deflate;q=0.5",
    "baggage": "trigger=api",
    "x-meta-hello": "thaJeztah"
},

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

Fix issue where custom meta-headers were not passed through when using the containerd image store.

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the 29.0.0 milestone Sep 23, 2025
@thaJeztah thaJeztah added area/distribution Image Distribution status/2-code-review impact/changelog kind/bugfix PR's that fix bugs containerd-integration Issues and PRs related to containerd integration labels Sep 23, 2025
@thaJeztah thaJeztah moved this to Required for default containerd in Containerd-as-default Sep 23, 2025
@thaJeztah thaJeztah marked this pull request as draft September 23, 2025 08:51
@thaJeztah

This comment was marked as resolved.

@thaJeztah

This comment was marked as resolved.

Similar to how [distribution.newRepository] in the legacy distribution code
passes the (custom) http-headers. User-Agent is always set, and can't be
overridden, so we apply it after setting the custom headers.

[distribution.newRepository]: https://github.com/moby/moby/blob/9ce272f804a9383c9aa593527d318c946bfb7b38/daemon/internal/distribution/registry.go#L74-L97

Before this patch:

    docker run --rm -d --name debugger -p 127.0.0.1:5001:8080 mendhak/http-https-echo
    DOCKER_CUSTOM_HEADERS=X-Meta-Hello=thaJeztah docker pull localhost:5001/myimage:latest
    docker logs debugger
    ...
    "headers": {
        "host": "localhost:5001",
        "user-agent": "docker/dev go/go1.24.7 git-commit/8e89fe7e8cbb3048f640846590175cbae4719b25 kernel/6.10.14-linuxkit os/linux arch/arm64 containerd-client/2.1.4+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/28.3.2 \\(linux\\))",
        "accept": "application/json, */*",
        "accept-encoding": "zstd;q=1.0, gzip;q=0.8, deflate;q=0.5",
        "baggage": "trigger=api"
    },

With this patch:

    docker run --rm -d --name debugger -p 127.0.0.1:5001:8080 mendhak/http-https-echo
    DOCKER_CUSTOM_HEADERS=X-Meta-Hello=thaJeztah docker pull localhost:5001/myimage:latest
    docker logs debugger
    ...
    "headers": {
        "host": "localhost:5001",
        "user-agent": "docker/dev go/go1.24.7 git-commit/8e89fe7e8cbb3048f640846590175cbae4719b25 kernel/6.10.14-linuxkit os/linux arch/arm64 containerd-client/2.1.4+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/28.3.2 \\(linux\\))",
        "accept": "application/json, */*",
        "accept-encoding": "zstd;q=1.0, gzip;q=0.8, deflate;q=0.5",
        "baggage": "trigger=api",
        "x-meta-hello": "thaJeztah"
    },

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

Yup, looks like we end up with a panic 🤔

Panic fixed, but looks like that means that docker build does not forward the X-Meta headers if set on the client; wondering if that's something to also fix (in a follow-up) 🤔

@thaJeztah thaJeztah marked this pull request as ready for review September 23, 2025 12:24
@vvoland vvoland merged commit 22016b5 into moby:master Sep 25, 2025
252 of 253 checks passed
@thaJeztah thaJeztah deleted the custom_metaheaders branch September 25, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/distribution Image Distribution containerd-integration Issues and PRs related to containerd integration impact/changelog kind/bugfix PR's that fix bugs status/2-code-review

Projects

Status: Required for default containerd

Development

Successfully merging this pull request may close these issues.

2 participants