jgallinari
Hello,
I made the switch recently from an x86 MacBook to Apple silicon (M3) and it seems to fail my Docker/Minikube workflow that perfectly worked under my old machine.
My app is a Phoenix app that is started in Minikube with a sidecar container (same pod) doing the migrations before the real app is started.
I’m using Elixir v1.15.7 with OTP v26.
FYI, the migrations are run in Dockerfile via
command: ['/home/elixir/app/bin/oss', 'eval', 'Oss.Migrator.migrate']
First thing, I found out there is no way to Docker build the app unless I add this ERL flag in the Dockerfile (as pointed out by Mix deps.get memory explosion when doing cross-platform Docker build]):
ENV ERL_FLAGS="+JPperf true"
or
ENV ERL_FLAGS="+JMsingle true"
I also had to use docker build --platform linux/amd64 to make it work in Minikube.
Then the rest of it:
- Run Docker Desktop.
- Start Minikube with
minikube start --extra-config=apiserver.service-node-port-range=1-50000 --memory=6g --cpus=4 --kubernetes-version=v1.22.15 --cni=calico --driver=docker
-
Docker build
-
Run the app in Minikube (via terraform apply), which causes this weird error while doing the migrations:
** (ArgumentError) could not call Module.put_attribute/3 because the module Oss.Repo.Migrations.CreatePopsTable is already compiled │
│ (elixir 1.15.7) lib/module.ex:2310: Module.assert_not_readonly!/2 │
│ (elixir 1.15.7) lib/module.ex:2007: Module.__put_attribute__/5 │
│ lib/oss-1.14.0/priv/repo/migrations/20210000000300_create_pois_table.exs:2: (module)
This error makes absolutely no sense to me, especially because it does not occur with my x86 MacBook.
If you think of anything I could try to sort this out, I’d be grateful for that
.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Tyson
I can’t speak to your specific migration error, but I’m surprised that you need to target x86 to build/run a Docker image in your local environment.
I’ve had to wrestle with cross-arch Elixir+Docker quirks when building images on my M1 Macbook to run on x86 hosts, but have had no issues building ARM images to run locally on my Macbook.
Tho I’m also using the k8s “cluster” built into Docker Desktop instead of
minikube.jgallinari
You’re absolutely right, I actually don’t need to build my Docker image with
.
--platform linux/amd64.I can now reproduce the same error with an arm64 image
jhogberg
Cross-architecture support in docker is iffy at best since it uses QEMU in user-mode emulation mode, which:
+JMsingle trueflag (implied by+JPperf true) works around the most egregious bugs, but not all.In short, don’t use cross-architecture docker unless you want to spice up your life with super-mysterious bugs.
Does the problem happen outside of a container? Does it work when disabling the JIT (
--disable-jitconfigure flag)?Tyson
Seems like other folks who have run into this were inadvertently using erlang/elixir installations (or macOS system libs) originally compiled for x86 and/or have Rosetta emulation enabled in their terminal. When you switched to your M3 Macbook, did you use Apple’s migration tool to move things over from your Intel machine? Could be some lingering x86 packages from that.
I believe @jhogberg is referring to using the
--disable-jitflag when configuring the Erlang build, which I have had good luck with when building cross-arch, but if you’re now using an ARM Docker image, I don’t think that’s the issue here.[edit: I believe Rosetta emulation only comes into play while installing elixir/erlang packages, as it may result in x86 versions being installed rather than native ARM]
[edit: my suggestions about macOS sys libs is probably irrelevant to your Docker build
]
jgallinari
Not sure where to add --disable-jit in my Dockerfile, I tried
with not much effect in the error happening.
To answer your questions:
In addition, I also did some trials by replacing Docker Desktop with Colima run like this:
which required adding the
--base-image gcr.io/k8s-minikube/kicbase:v0.0.40option tominikube startto make it work, like reported in Starting Minikube messes up binfmt config for Docker, making it unable to run cross-architecture images · Issue #17700 · kubernetes/minikube · GitHub because Minikube v1.32.0 which is based on kicbase:v0.0.42 causes issues with Colima (not only OrbStack as mentioned in the Minikube issue).That to say that since I use the Apple Virtualization Framework + Rosetta enabled in Colima, QEMU is not in use in my workflow.
But using Colima stills results in the exact same error
Tyson
I’m still struggling with this part:
I’ve never needed to do any extra config to build ARM images to run on my local ARM machine. I’ve only had to mess with that while building on ARM for x86 platform. Are you sure the Elixir base image you’re using is also ARM? For instance:
But in case this is helpful (and maybe there’s a more elegant way to do this), you can copy the Erlang Dockerfile and update it to read:
…then build the Erlang image, then create a local copy of the Elixir Dockerfile to build
FROM ...that local Erlang image in order to create your own JIT-disabled Elixir base image.Tyson
One more thing I’ll add: in some circumstances I’ve found it necessary to specify the platform in the Dockerfile (rather than with the
docker buildflag):Not sure why that sometimes makes a difference.
jgallinari
That’s the output I get indeed.
If I don’t use
in the Dockerfile, then
And this I get while calling
docker buildwithout specifying a plaftorm, but usingFROM --platform=linux/amd64 <custom-elixir-alpine-image>Tyson
Why specify AMD platform for something you’re going to run locally on ARM?
Tyson
This doesn’t really sound like an issue with the architecture. Sounds like
:ssl_app.start(:normal, [])is not a valid invocation with empty list.[edit: but I guess you’re not calling that, so could be some cross-arch fallout]