-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'platform' option in docker_container #123
Comments
I'm not sure what that flag should do. Do you mean it should be used when the image needs to be pulled? You could use the |
To be honest — I'm not sure :) All in all, I was thinking about the Currently, if I use
|
I looked at the source code of the of the docker CLI client, and found out that container creation accepts a query parameter Unfortunately, this is not documented in the API docs: https://docs.docker.com/engine/api/v1.41/#operation/ContainerCreate (it only documents the query parameter Until the Docker SDK for Python supports this, we can't implement it, unfortunately. I raised an issue for that in its repository: docker/docker-py#2822 |
Thanks for looking into this! Just in case I took a look at the docker-py documentation — I'm not sure which method are you exactly talking about, but I can see that there's a |
Ah, I see, it's not supported in the low-level API you're using. Strange enough. |
Yes, I was looking at the low-level API (https://docker-py.readthedocs.io/en/stable/api.html#module-docker.api.container), since that's the one we are using. |
I checked the sources for |
Adding as a side note that this is a useful feature for cross-arch testing if you have already setup Docker to use qemu with buildx and setup a custom builder, then having this option on docker_container is useful. It prevents the need to have to use Docker image to pre-pull each platform image before using it (since the local image store can only have one platform per image tag even if the tag in the upstream repository references a multi-arch/platform image manifest). Kind of weird that the low level API's didnt implement that, so pre-pulling the images seems to be the only viable workaround currently. |
I agree. Actually I created a PR for Docker SDK for Python to implement this more than a month ago (docker/docker-py#2927), but the repo maintainers apparently haven't taken a look so far... |
Searching for "m1" doesn't show anything in the issue tracker, so commenting here just to be explicit: this would be ultra ultra helpful for Apple M1 users. Specifying platform "linux/amd64" would let us run x86 containers in Docker, which is needed if there are no ARM builds of the container available. |
Ive managed to move my platform over to ansible-core 2.11 and work around all the issues here without too much of a fuss. The only real issue is with the image downloads... if you already have an image for one architecture locally, you have to use the So if you dont mind pre-pulling your image for the architecture you want, it still works ok. Im using Linux primarily, but a few of my teammates have got this going on Macs as well (not sure if they were M1s specifically). This pre-pull with |
Blocked on docker-py being unmaintained. New ansible issue on that: #364 |
Hero-grade work @felixfontein; thank you so very much for taking care of these critical roles. |
SUMMARY
It would've been great to have a
platform
option in docker_container. E.g. in some strange cases, you could want to run thelinux/386
container onlinux/amd64
.ISSUE TYPE
COMPONENT NAME
docker_container
The text was updated successfully, but these errors were encountered: