I have an absolutely empty elixir 1.10.2 app that once I’ve done
<fix-up config files>
MIX_ENV=prod mix release
The application builds and runs fine. But when I dockerize it,
docker build -t sock_app .
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
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.
That was it! Nice one, thanks.
Pushed it to the repo if anyone is interested.
This file has been truncated.
# The directory Mix will write compiled artifacts to.
# If you run "mix test --cover", coverage assets end up here.
# The directory Mix downloads your dependencies sources to.
# Where 3rd-party dependencies like ExDoc output generated docs.
# Ignore .fetch files in case you like to edit your project deps locally.
# If the VM crashes, it generates a dump, let's ignore it too.
# Also ignore archive artifacts (built via "mix archive.build").
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 .