Trivial Elixir app: release build runs but docker runtime error from erlexec

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.

Any ideas? The code can be found at:

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.

Similar problem:


That was it! Nice one, thanks.

Pushed it to the repo if anyone is interested.


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.

Now build your image with Docker like so

docker buildx build --platform linux/amd64 -t my_image_tag .