Send platform as a query parameter on container create - #607
Open
tas50 wants to merge 1 commit into
Open
Conversation
/containers/create takes `platform` as a query parameter. Docker::Container.create
forwarded only `name` to the query string and dumped everything else into the
request body, so a caller asking for a platform got it placed in the body, where
the daemon accepts and silently ignores it:
QUERY={"name" => "dapi-plat"}
requested linux/amd64 on an arm64 host -> got arm64
Nothing raised. The container simply came up on the wrong architecture, which is
the worst way for this to fail.
Pull the query keys out into CREATE_QUERY_KEYS and route both name and platform
through it. With the fix the daemon actually sees the parameter, and asking for a
platform the local image does not provide now reports that:
image with reference alpine:latest was found but does not provide
the specified platform (linux/arm64)
Not a breaking change: `platform` previously had no effect wherever it was
placed, so no caller can be relying on the old behaviour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/containers/createtakesplatformas a query parameter.Docker::Container.createforwarded onlynameto the query string and dumped everything else into the request body, so a caller asking for a platform got it placed in the body — where the daemon accepts and silently ignores it.The bug
Nothing raised. The container just came up on the wrong architecture. This is why kitchen-dokken bypasses the gem entirely and posts to
/containers/createby hand.The fix
Pull the query keys into
CREATE_QUERY_KEYSand route bothnameandplatformthrough it.Verification
The query parameter now reaches the daemon:
And the daemon acts on it. With only the amd64 variant of alpine present locally, asking for arm64 is now correctly rejected instead of silently starting an amd64 container:
Two specs cover it — one asserting
platformreaches the query string, one asserting it is absent from the body. Both were confirmed to fail before the change:62 examples across the container, exec, network, volume and top-level specs pass with the change.
Compatibility
Not a breaking change —
platformpreviously had no effect wherever it was placed, so nothing can be relying on the old behaviour.CI will be red until #605 lands; this branch is off master, where the workflow is currently broken for unrelated reasons.