2

I encountered a wired problem with Erlang 20 .

I use rebar3 as prod tar to generate an archived file and I use this to build an docker image based on erlang:20.2-alpine.

On my Macbook Pro, it is ok to call bin/app start but on the target docker container, it tells me: erts-9.2/bin/erlexec: line 1: syntax error: unexpected "("

Erlang on my Macbook Pro:

erl
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V9.2  (abort with ^G)

Erlang on the target container:

erl
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V9.2  (abort with ^G)```
Yuanbo Han
  • 75
  • 8
  • 3
    Note that `erlexec` is a compiled executable program. You're likely trying to run an `erlexec` built for OS X in a Linux container. Try checking what kind of file `erlexec` is in the container by running `file /erts-9.2/bin/erlexec`. – Steve Vinoski Dec 23 '17 at 14:28
  • Thanks for you advice, I directly use the Alpine container to build the release – Yuanbo Han Dec 24 '17 at 18:10

2 Answers2

8

Tldr; Add a .dockerignore file to your project that ignores the _build directory.

I had this problem today. Like @steve-vinoski mentioned in the comments, it did have to do with the fact that I was running a macOS output in the container but like @yuanbo-han, I too am building the release in the Dockerfile so I couldn't figure out why it wasn't working.

Then I realized, I had a COPY . . directive in my Dockerfile that was picking up the output from my mac because I didn't have a .dockerignore in place. The solution was to add the following .dockerignore file to the root of the project:

_build/
.elixir_ls/
.git/
.vscode/
deps/
priv/static/
test/
.dockerignore
.env
.formatter.exs
.gitignore
.travis.yml
Dockerfile
README.md
groksrc
  • 2,910
  • 1
  • 29
  • 29
0

I reference docker erlang, use docker to directly build release and target image.

Yuanbo Han
  • 75
  • 8