ansible-collections / community.docker

Community Docker Collection for Ansible: modules and plugins for working with Docker
https://galaxy.ansible.com/ui/repo/published/community/docker/
GNU General Public License v3.0
199 stars 113 forks source link

Building multi-platform Docker images #467

Open sheromon opened 2 years ago

sheromon commented 2 years ago
SUMMARY

I would like to be able to build multi-platform Docker images similar to what is described in the Docker documentation here: https://docs.docker.com/build/buildx/multiplatform-images/. A relevant example command from that page is docker buildx build --platform linux/amd64,linux/arm64 ..

ISSUE TYPE
COMPONENT NAME

docker_image

ADDITIONAL INFORMATION

I have been using the build.platform option to let me build amd64 images on an M1 Mac, and that has worked well for me (thank you for that!), but I would like to be able to build a multi-platform Docker image for both arm64 and amd64 at the same time.

felixfontein commented 2 years ago

The docker_image module uses the Docker daemon for building images. That's not the same as docker buildx does, and it does support a lot less features. So this is not possible with what the module uses. (You can find some details on this in #364.)

If someone wants to implement using buildx / the docker CLI tool, I think it should be a new module docker_image_build to avoid breaking backwards compatibility (or making the existing docker_image module even more complex).

sheromon commented 2 years ago

Thank you for the information! I'm new to working with this, so I wasn't familiar with how it works behind the scenes or the question/discussion in #364.

felixfontein commented 2 years ago

I created a PR to mention this in the docs: #468.