I have an absolutely empty elixir 1.10.2 app that once I’ve done mix release.init <fix-up config files> MIX_ENV=prod mix release
and finally: _build/prod/rel/sock_app/bin/sock_app start
The application builds and runs fine. But when I dockerize it,
docker build -t sock_app .
and do:
docker run -p 4004:4004 sock_app
I immediately get the runtime error:
/app/erts-10.6.1/bin/erlexec: line 1: syntax error: unexpected "("
I’ve re-written the Dockerfile a few times but always end-up with this error.
I had similar problems recently. I think it may have to do with things getting compiled on the host machine and leaking into the Docker container causing problems. I would try creating a .dockerignore and adding things like _build/, deps, and anything else that isn’t actually required to build the app to make sure nothing that got build on your host machine leaks in to the container. Since Alpine uses MUSL that would cause problems. Definitely ignore those two at least.
I got this error building on OSX M1 chip. Running file command on erlexec show that it is build for ARM architecture even withing Docker container.
If you on ARM processor aka. Mac M1 go to Docker Setting → Experimental and enable Use New Virtualization Framework
This will add new docker buildx command.