Skip to content

Send platform as a query parameter on container create - #607

Merged
ls-todd-lunter merged 2 commits into
upserve:masterfrom
tas50:fix-container-create-platform
Oct 24, 2026
Merged

ls-todd-lunter merged 2 commits into
upserve:masterfrom
tas50:fix-container-create-platform

Conversation

@tas50

@tas50 tas50 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

/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.

The bug

QUERY={"name" => "dapi-plat"}
requested linux/amd64 on an arm64 host -> resulting container arch = arm64

Nothing raised. The container just came up on the wrong architecture. This is why kitchen-dokken bypasses the gem entirely and posts to /containers/create by hand.

The fix

Pull the query keys into CREATE_QUERY_KEYS and route both name and platform through it.

Verification

The query parameter now reaches the daemon:

POST /containers/create QUERY={"name" => "dapi-plat3", "platform" => "linux/amd64"}

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:

image with reference alpine:latest was found but does not provide
the specified platform (linux/arm64)

Two specs cover it — one asserting platform reaches the query string, one asserting it is absent from the body. Both were confirmed to fail before the change:

expected: ("/containers/create", hash_including("platform" => "linux/amd64"), anything)
     got: ("/containers/create", {}, {body: "{...,\"platform\":\"linux/amd64\"}"})

62 examples across the container, exec, network, volume and top-level specs pass with the change.

Compatibility

Not a breaking change — platform previously 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.

tas50 and others added 2 commits August 23, 2026 12:36
/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.
@ls-todd-lunter
ls-todd-lunter merged commit badc017 into upserve:master Oct 24, 2026
32 checks passed
ls-todd-lunter added a commit that referenced this pull request Oct 27, 2026
* Declare base64 as a runtime dependency so the gem loads on Ruby 3.4+ (#605)
* Replace multi_json with the json standard library and drop the multi_json dependency (#613)
* Keep the build context inside the build directory: symlinks are archived as symlinks rather than followed, and .dockerignore patterns can no longer reach outside the directory (#611)
* Send platform as a query parameter on Container.create (#607)
* Honor stdout: false and stderr: false in Container#exec (#609)
* Request an HTTP upgrade when attaching to stdin so the attach no longer hangs (#610)
* Memoize Connection#rootless? when the daemon is not rootless (#608)
* Add gemspec metadata (source_code_uri, bug_tracker_uri, rubygems_mfa_required) and build the gem file list without git (#615)
* Fix and update README examples and streaming read_timeout docs (#606, #585, #592)
* Fix CI, test through Ruby 4.0 and Docker 28 and 29, and remove Travis, Code Climate and unmaintained test image leftovers (#604, #605, #614, #616)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants