#How does dagger engine choose arm vs amd64?

1 messages · Page 1 of 1 (latest)

tranquil mauve
#

This is a bit of a follow up to this thread -> #java message

How does dagger choose the architecture it's running under? Usin a mac m1, and generally im experiencing confusing behavior that is different than I see with docker. kind of challenging to troubleshoot. getting errors preventing binaries from running, sometimes containers building with not the right architecture, and strangley some processes running with qemu?!?

Is there any detail I can see as to what's happening here?

#

Working on an all-in one reproduction example here, but here's a couple snippets of something weird I'm seeing while trying to troubleshoot.

# build base container
➜  golang-cli git:(stobias/minor-fixes) ✗ export DOCKER_DEFAULT_PLATFORM="linux/amd64"                    
➜  golang-cli git:(stobias/minor-fixes) ✗ docker build -t acct.dkr.ecr.us-west-2.amazonaws.com/infrastructure/java-base:latest-build-env6 .
➜  git:(stobias/fix-client-timeout) ✗ docker run -it --entrypoint /bin/bash foo.dkr.ecr.us-west-2.amazonaws.com/infrastructure/java-base:latest-build-env6
root@7c673f68944d:/src# uname -a
Linux 7c673f68944d 6.5.11-linuxkit #1 SMP PREEMPT Wed Dec  6 17:08:31 UTC 2023 x86_64 GNU/Linux

Then in dagger....

func (k *KotlinBuilder) getKotlinBuildTools() *dagger.Container {
    cacheDir := k.client.CacheVolume(k.version + "-cache")
    return k.client.Container(dagger.ContainerOpts{Platform: "linux/amd64"}).From(constants.KOTLIN_BUILDER_IMAGE_BASE).
        WithEnvVariable("GRADLE_USER_HOME", "/root/.gradle")

Then In my test case

//kotlin_builder_test.go
    ctr := kotlinBuilder.getKotlinBuildTools().
        WithMountedDirectory("/src", src).
        WithWorkdir("/src")
    _, err = ctr.WithExec([]string{"uname", "-a"}).Sync(ctx)

Then the test will throw error indicative of what I think is an architecture mismatch?


29: exec /bin/bash uname -a
29: [1.21s] /bin/uname: /bin/uname: cannot execute binary file
29: exec /bin/bash uname -a ERROR: process "/bin/bash uname -a" did not complete successfully: exit code: 126
#

How does dagger engine choose arm vs amd64?

normal mantle
#

You can force an architecture on a container, for instance

#

Not sure if that helps.

#

Those are both Zenith modules, but same principle applies.

tranquil mauve
#

yeah forcing architecture in the snippets above

normal mantle
#

Is there a minimal repro I can try?

tranquil mauve
#

I'm trying one more workaround ,seeing if I can just build from dagger entirely rather than using docker

#

My best guess is that maybe there's a difference in how docker daemon is deciding architecture vs dagger

#

are you on m1/2/3?

normal mantle
#

yep m1

tranquil mauve
#

hmm this was embarassingly an issue with the image entrypoint

#

not sure how I got things mixed up, I swear there were architecture errors in there somewhere 😅

#

I do have to explicitly set linux/amd64 though

outer sail
#

if the container you're trying to build is amd64 specific, you need to explicitily set that