Fl4m3Ph03n1x

Fl4m3Ph03n1x

Docker of mix release crashes with "Exec format error"

Background

I have an executable created via mix release which works just fine when I run it with start on my local machine. However, my docker image crashes when trying to start the executable and I don’t know why.

Docker

FROM elixir:1.10

# Install Hex + Rebar
RUN mix do local.hex --force, local.rebar --force

COPY . /
WORKDIR /

ENV MIX_ENV=prod
RUN mix do deps.get --only $MIX_ENV, deps.compile
RUN mix release

EXPOSE 8080
ENV PORT=8080
ENV SHELL=/bin/bash

CMD ["_build/prod/rel/my_app/bin/my_app", "start"]

This is my docker file. It does nothing special other than compiling and then trying to run the release via start.

Error

However, when I execute the docker image with docker run -p 8080:8080 my-app:1.0 docker crashes:

/_build/prod/rel/my_app/releases/0.1.0/../../erts-10.5/bin/erl: 12: exec: /_build/prod/rel/my_app/erts-10.5/bin/erlexec: Exec format error

Research

At first I thought this was happening because the file _build/prod/rel/my_app/bin/my_app was missing #!/usr/bin/env bash at the top.

While indeed it doesn’t have that, it has something else that should equally work: #!/bin/sh

So this theory is out.

Another thing that may be possible is that, since this is the release of an umbrella app (in which there are 3 apps) maybe there is a race condition in launching the apps that is causing an internal error and makes the image crash.

However, I can’t confirm this.

Question

Is something wrong with my Dockerfile?
How can I get rid this error?

Marked As Solved

al2o3cr

al2o3cr

Are you excluding _build and deps from your Docker build? This post suggests that might help avoid cross-compilation headaches.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

We're in Beta

About us Mission Statement