#build docker image for given platform

1 messages Β· Page 1 of 1 (latest)

viral crane
#

Hello there, happy new year! πŸ₯³

I am on a Macbook having an Apple Silicon chip (arm64).
I would like to build a docker image for linux/amd64 but it doesn't seem to work if I specify FROM --platform=linux/amd64 in my Dockerfile. Also the Dagger Go SDK doesn't seem to allow me to specify the target platform in Go.

My code:

// build docker image
buildOpts := dagger.ContainerBuildOpts{
  Dockerfile: "./Dockerfile",
}
myContainer := client.Container().Build(src, buildOpts)

Thanks. πŸ™‚

wise cedar
#

Hi @viral crane ! I believe client.Container() has an optional platform argument ?

#

I’m not sure how that interacts with dockerfile support specifically though

viral crane
#

Oh, you are right!

// func (r *Query) Container(opts ...ContainerOpts) *Container

type ContainerOpts struct {
    ID ContainerID

    Platform Platform
}
#

I only looked at ```go
dagger.ContainerBuildOpts{
Dockerfile: "./Dockerfile",
}

and thought it missed the platform.
#

I'll try that today ! 😁

viral crane
#

if I can force it in Go, I'm a happy coder πŸ™‚

wise cedar
viral crane
#

oh, ok. Maybe client.Container() takes precedence over the --platform in the Dockerfile.

neat canopy