c0b / docker-elixir

Official Docker image for Elixir :whale: :turtle: :rocket:
http://elixir-lang.org/
190 stars 73 forks source link

Elixir fails with error 'dlsym: Resource temporarily unavailable' #117

Open 1player opened 5 years ago

1player commented 5 years ago

Our app in production is built in two stages from image elixir:1.8.2-alpine and runs on alpine and recent builds (some time in the last 10 days or so) have failed to start at all with error "dlsym: Resource temporarily unavailable".

I've noticed all the elixir images have been rebuilt 5 days ago.

Forcing images to be built off the last working image SHA elixir:1.8.2-alpine@sha256:cd04d80e85430b803f185553176803d935ead138322904d029ff6a9f7dbcd2a1 and run off alpine@sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6 fixes the error. Not sure which of the two images is the culprit.

There's a relevant bug report on Alpine Linux about this: https://bugs.alpinelinux.org/issues/9983

I reckon the images should be tested somehow before pushing to Docker Hub, as currently even a simple elixir -v fails with the above error.

c0b commented 5 years ago

could you tell which latest images (with sha256) have the problems?

I am checking it as of now, get the elixir:1.8.2-alpine@sha256:36f0e4f55851db29ec9ff7ad5f309266967bd13647a55d508408509d9bbb4d37, with the default cmd is iex when iex works, the elixir -v also work,

➸ docker image pull 'elixir:1.8.2-alpine'
1.8.2-alpine: Pulling from library/elixir
Digest: sha256:36f0e4f55851db29ec9ff7ad5f309266967bd13647a55d508408509d9bbb4d37
Status: Downloaded newer image for elixir:1.8.2-alpine
➸ docker image pull 'elixir:1.8.2-alpine@sha256:36f0e4f55851db29ec9ff7ad5f309266967bd13647a55d508408509d9bbb4d37'
1.8.2-alpine: Pulling from library/elixir
Digest: sha256:36f0e4f55851db29ec9ff7ad5f309266967bd13647a55d508408509d9bbb4d37
Status: Downloaded newer image for elixir:1.8.2-alpine
➸ docker container run -it --rm 'elixir:1.8.2-alpine@sha256:36f0e4f55851db29ec9ff7ad5f309266967bd13647a55d508408509d9bbb4d37'
Erlang/OTP 21 [erts-10.3.5.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> System.get_env "OTP_VERSION"
"21.3.8.4"
iex(2)> System.get_env "ELIXIR_VERSION"
"v1.8.2"
iex(3)> 
➸ docker container run -it --rm 'elixir:1.8.2-alpine@sha256:36f0e4f55851db29ec9ff7ad5f309266967bd13647a55d508408509d9bbb4d37' sh
/ # elixir -v
Erlang/OTP 21 [erts-10.3.5.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.8.2 (compiled with Erlang/OTP 21)
/ # 

https://bugs.alpinelinux.org/issues/9983

$> docker run --rm -it alpine:edge
/ # apk add elixir
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
[...]

Just let you know, if you read the Dockerfile here, the alpine version does not use the apk add elixir it does not use the alpine precompiled version of elixir,

What in use in this alpine version of Elixir Dockerfile is to compile from source code, we discussed all the pros and cons during beginning of this Erlang & Elixir git repo, we chose the approach to compile everything from scratch, either a Debian based buildpack-deps or the bare alpine image;

I reckon the images should be tested somehow before pushing to Docker Hub, as currently even a simple elixir -v fails with the above error.

Yes, the pushing process is controlled by upstream docker-library/official-images and the test&verification process you suggested is already there, since beginning we pushed to the official-images, we added the elixir-hello-world test there, every elixir image has to pass the run.sh test which calls a simple exs script, and output must match the expected-std-out.txt ; the process is called in an upstream CI step, it has to succeed before it can be pushed to Docker Hub

https://github.com/docker-library/official-images/tree/master/test/tests/elixir-hello-world

1player commented 5 years ago

Thanks @c0b for the detailed response.

I've done further tests, and the problem is not on the elixir image itself, but on alpine or alpine:edge or its compability with the elixir image.

Unfortunately, the only way to reproduce I have is using our app multistage Dockerfile, attached here: https://gist.github.com/1player/765cec58bbda39d86df23b10cddc8c8b

Contrarily to what I previously said, any elixir:1.8.2-alpine image works on the first stage, but the second stage requires alpine@sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6 or docker will simply spit out the error in title. Also fails with alpine:edge.

I also made sure the tini entrypoint is not the problem, by running a shell in the image and starting the main executable generated by the release/Distillery:

$ docker run -it <snip> --entrypoint /bin/sh hive
### In the container
/ # /app/bin/hive
dlsym: Resource temporarily unavailable
/ # /app/erts-10.3.5.1/bin/erl
dlsym: Resource temporarily unavailable
Aborted

So it seems it's an upstream Alpine bug, though I'll leave the issue open in case you think it might be somehow related to the elixir image, or if you know how can I debug this further, but otherwise feel free to close it.

rinpatch commented 5 years ago

Related to erlang/docker-erlang-otp#235