Hi, when building a docker image (and pushing it) ...
# aws
c
Hi, when building a docker image (and pushing it) with awsx.ecr.Image I get this error:
Copy code
error: ERROR: Multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
I have
'--platform', 'linux/amd64,linux/arm64'
as extraOptions. Is there any way to use this with awsx.ecr.Image? I'm using MAC M1
p
AFAIK Pulumi AWSX uses Pulumi Docker v3 which is a wrapper around Docker CLI. This means that is uses
docker build
under the hood. To build the Docker image for multiple platforms, you need to use BuildKit builder. To use BuildKit as the default builder, you need to create a new builder instance and use it using
Copy code
docker buildx create --use
which is exactly what the error message says. (Otherwise, without using
--use
you would have to build the image with
docker buildx build
to use BuildKit, which is not what the Pulumi Docker v3 is doing.)
c
So there is no way to build docker image for multiple platforms with pulumi?
p
There is, as I already posted. You just need to setup BuildKit as the default builder with the
docker buildx create --use
command before running
pulumi up
. That will create the BuildKit instance and actually use it, which means calling
docker build
will effectively mean
docker buildx build
. If you provision the resources during CI pipeline, do it before the provisioning step. E.g. for GitHub Actions there's setup-buildx-action that will do it for you. (You'll also need the setup-qemu-action to build for multiple platforms on the x86 GitHub runners.)
c
I'm running
docker buildx create --use
on my local machine or? Because I did and I still get the same error
s
This doesn’t answer your original question (and @proud-art-41399 is correct, this is due to
awsx.ecr.Image
using an embedded v3 Docker provider), but what I’ve done in the past is specify only
linux/amd64
since most of the systems I deploy on AWS are x86_64. In theory, you should also be able to use the Docker v4 provider to build the image, and then push it separately (instead of using
awsx.ecr.Image
). I haven’t tested that yet.
s
I would think so, yes. Haven’t tried it personally myself, but based on a quick perusal of the code it looks a lot like what I was thinking in my head. 🙂
c
I will try it out. Thanks to both of you for help 🙂
s
Of course, happy to help!
p
Problems like this is why I don't use AWSX any more and stitch everything myself using lower level components. That lets me use Pulumi Docker v4 (as @salmon-account-74572 mentioned) which uses BuildKit by default. On the other hand, Pulumi Docker v4 currenly doesn't support specifying multiple platforms for a single Docker image resource. You can however create two resources, one for each architecture.