msaraiva / alpine-erlang Goto Github PK
View Code? Open in Web Editor NEWMinimal Erlang/Elixir docker images with Alpine Linux
Minimal Erlang/Elixir docker images with Alpine Linux
Hello, first of all thanks for this well done image.
I'm facing the following issue, a bit of context first:
The image works like a charm on my local machine (vagrant), but on the CI (circleci) it fails with "Segmentation fault":
Status: Downloaded newer image for msaraiva/elixir-dev:latest
---> 222954f834bb
Step 1 : ADD mix.exs /app/mix.exs
---> 59306404aad1
Step 2 : WORKDIR /app
---> Running in a4a02abe52f6
---> 0b757798a367
Step 3 : RUN yes | mix local.hex
---> Running in bf1aa4ff8da1
Segmentation fault (core dumped)
The command '/bin/sh -c yes | mix local.hex' returned a non-zero code: 139
I wanted to ask if you have any clues on how to solve this. Thanks
I've built a Phoenix app following the directions, with some minor tweaks. Specifically, since I'm using Erlang 18.3, I'm using the "alpine:3.4" Docker image, and then updating Erlang (which shows it gets 18.3). But, when I run I see:
# docker run --rm -p 4000:4000 lana
created directory: '/lana/running-config'
Exec: /usr/lib/erlang/erts-7.3.1/bin/erlexec -noshell -noinput +Bd -boot /lana/releases/0.0.1/lana -mode embedded -config /lana/running-config/sys.config.2.config -boot_var ERTS_LIB_DIR /usr/lib/erlang/erts-7.3.1/../lib -env ERL_LIBS /lana/lib -pa /lana/lib/lana-0.0.1/consolidated -args_file /lana/running-config/vm.args.2.config -- foreground
Root: /lana
{"init terminating in do_boot",{'cannot load',asn1rt_nif,get_files}}
My Dockerfile is the same as the example, except for the first two lines which I've changed to:
FROM alpine:3.4
RUN apk --update add erlang erlang-crypto erlang-sasl erlang-syntax-tools && rm -rf /var/cache/apk/*
From some Googling, it seems the "asn1rt_nif" has something to do with crypto stuff maybe? But it seems I need the erlang-crypto
, etc. Anyone have ideas on what I might be doing wrong, or have mismatched, or what to investigate?
Hi there, I'm writing an issue also here after creating erlangpack/erlang-oauth#28 since I'm not sure where's the reason of my issue.
The problem is this:
==> oauth
{"init terminating in do_boot",{undef,[{make,all,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
Makefile:7: recipe for target 'compile' failed
make: *** [compile] User defined signal 2
Looking at erlangpack/erlang-oauth#25 seems that they're complaining about having "full erlang" but I see in your erlang base image that you install the full package from alpine linux.
Is there something else that has to be done on the docker side I'm missing?
When installing Erlang package in alpine linux via this command line
apk add --update erlang --update-cache --allow-untrusted -X http://dl-4.alpinelinux.org/alpine/edge/community/
I got the following error:
ERROR: unsatisfiable constraints:
so:libncurses.so.6 (missing):
required by: erlang-18.1-r3[so:libncurses.so.6]
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello_nif$ sudo docker build -t kklepper/hello_nif:alpine .
Sending build context to Docker daemon 14.85 kB
Step 1 : FROM msaraiva/erlang:18.1
---> a3f284987480
Step 2 : ADD hello_nif /app/hello_nif
lstat hello_nif: no such file or directory
Just to let you know -- I don't know how to fix that (I suppose hello to be some kind of Erlang construct):
ubuntu@ip-172-31-30-16:~$ mkcd msaraiva
ubuntu@ip-172-31-30-16:~/msaraiva$ git clone https://github.com/msaraiva/docker-alpine-examples
Cloning into 'docker-alpine-examples'...
remote: Counting objects: 204, done.
Receiving objects: 100% (204/204), 1.98 MiB | 385.00 KiB/s, done.
remote: Total 204 (delta 0), reused 0 (delta 0), pack-reused 204
Resolving deltas: 100% (57/57), done.
Checking connectivity... done.
ubuntu@ip-172-31-30-16:~/msaraiva$ cd docker-alpine-examples/hello
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello$ MIX_ENV=prod mix escript.build
The program 'mix' is currently not installed. You can install it by typing:
sudo apt-get install anon-proxy
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello$ docker build -t hello .
Sending build context to Docker daemon 12.29 kB
Step 1 : FROM msaraiva/erlang:18.1
18.1: Pulling from msaraiva/erlang
8f4ec95ceaee: Pull complete
a3ed95caeb02: Pull complete
9a5d24db1f61: Pull complete
Digest: sha256:8e36cd943118112a9fdbb82dbce6de6f428fff3501f98b00c4025bf4b033364f
Status: Downloaded newer image for msaraiva/erlang:18.1
---> a3f284987480
Step 2 : ADD hello /usr/local/bin/hello
lstat hello: no such file or directory
Hello Markus!
On AWS t2.micro Ubuntu 14.04:
ubuntu@ip-172-31-30-16:~/kklepper/alpine/erlang$ docker run -it --rm kklepper/erlang:alpine ash
/ # erl
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [async-threads:10] [kernel-poll:false]
Eshell V7.1 (abort with ^G)
1> crypto:start().
** exception error: undefined function crypto:start/0
In consequence, rebar will not work, needed for building yaws.
/ # find -type f -name *crypto*
./proc/crypto
/usr/lib/libcrypto.so.1.0.0
Any idea how to fix or to get around this? I'm afraid I'm not experienced enough to build yaws from scratch.
/Karl
Hi! Thank you so much for the Dockerfile template!! It was awesome to get my first image build following the hello_phoenix example!
However, when I attempted to do docker run
on the image. I came across this error.
{error_logger,{{2016,2,17},{7,15,51}},"Unable to load crypto library. Failed with error:~n\"~p,
~s\"~nOpenSSL might not be installed on this system.~n",[load_failed,"Failed to load NIF library:
'Error loading shared library /content_ui/lib/crypto-3.6.1/priv/lib/crypto.so: Exec format error'"]}
I can't seem to get pass this error, even with building the image from alpine.
If it is not too much hassle, would you mind giving me some directions on how to resolve this issue?
Quite interesting: this container doesn't even run and gives no error:
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello$ docker run --rm -v $PWD:$PWD -w $PWD -e "MIX_ENV=prod" msaraiva/elixir sh -c "mix escript.build"
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
msaraiva/elixir latest a66cb333e64d 5 weeks ago 23.11 MB
msaraiva/erlang 18.1 a3f284987480 11 weeks ago 18.3 MB
I'll replace/remove some of the Erlang/Elixir images available on Docker Hub. The reason is that all the images that depend on the apk
packages will now follow the official releases from Alpine Linux. That means after the release of the upcoming AL version 3.3, there will be only two versions of erlang, "18.1"(latest) and "edge". All newer versions will replace the "edge" version until the next release of AL and then the erlang version gets "frozen" among the the AL version. After this change there will be only the following images available:
All other images will be removed.
For Elixir versions that might, in the future, depend on newer releases of Erlang, we could also have:
This way we can avoid conflicts and instability since we ensure that all releases, except the ones tagged as "edge", will always depend on the same apk
package.
Cheers!
-marlus
Using Alpine-Erlang in a Elixir distributed network, when call "Node.connect" to a Docker-Alpine node, it's constantly reporting false. If I start a node without Docker-Alpine, all the other nodes can successfully "Node.connect" to this Non-Docker-Alpine node.
Seems not to be a problem with docker since the distributed network port has been set to 9001(Also EXPOSE in docker file) and firewall is also not blocking the traffic. Using ubuntu-erlang package seems to be working OK as well.
Does this relate to any missing Erlang dependencies( https://pkgs.alpinelinux.org/packages?name=erlang%25&repo=all&arch=x86_64&maintainer=all ) that I need to put into dockerfile during the building process? Or there should be some Alpine packages that need to be installed?
Hello
When trying to run docker build -t hello_phoenix .
in the hello_phoenix example I get:
Sending build context to Docker daemon 18.54 MB
Step 1 : FROM msaraiva/alpine-elixir-base:18.0
---> 4e6156316eb5
Step 2 : RUN apk update
---> Running in d429cc6402e3
fetch http://dl-4.alpinelinux.org/alpine/v3.2/main/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
v3.2.3-144-gb61c35e [http://dl-4.alpinelinux.org/alpine/v3.2/main]
v3.3.0_rc3-189-ga37b626 [http://dl-4.alpinelinux.org/alpine/edge/main]
OK: 10619 distinct packages available
---> 25c7c052f9cf
Removing intermediate container d429cc6402e3
Step 3 : RUN apk update && apk --update add erlang-sasl && rm -rf /var/cache/apk/*
---> Running in 54be7cdb4e92
fetch http://dl-4.alpinelinux.org/alpine/v3.2/main/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
v3.2.3-144-gb61c35e [http://dl-4.alpinelinux.org/alpine/v3.2/main]
v3.3.0_rc3-189-ga37b626 [http://dl-4.alpinelinux.org/alpine/edge/main]
OK: 10619 distinct packages available
fetch http://dl-4.alpinelinux.org/alpine/v3.2/main/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
erlang-sasl (missing):
required by: world[erlang-sasl]
The command '/bin/sh -c apk update && apk --update add erlang-sasl && rm -rf /var/cache/apk/*' returned a non-zero code: 1
I'm new to alpine linux, did I do something wrong? Thanks for your help!
I saw @msaraiva is maintaining the elixir/erlang packages in the official alpine repository, do you have any plan to upgrade it in edge?
Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.6.6 (compiled with OTP 19)
Operating system:
kali Linux
mix phoenix.new --no-brunch phoenix_trello
06:53:45.220 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library /usr/lib/erlang/lib/crypto-4.3/priv/lib/crypto: 'libcrypto.so.1.0.0: cannot open shared object file: No such file or directory'"
OpenSSL might not be installed on this system.
06:53:45.386 [warn] The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library /usr/lib/erlang/lib/crypto-4.3/priv/lib/crypto: 'libcrypto.so.1.0.0: cannot open shared object file: No such file or directory''}}
** (UndefinedFunctionError) function :crypto.strong_rand_bytes/1 is undefined (module :crypto is not available)
:crypto.strong_rand_bytes(64)
lib/mix/tasks/phoenix.new.ex:484: Mix.Tasks.Phoenix.New.random_string/1
lib/mix/tasks/phoenix.new.ex:223: Mix.Tasks.Phoenix.New.run/4
(mix) lib/mix/task.ex:314: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2
To make a directory of phoenix_trello
When run hello_phoenix example, it kept reporting error. Seems the problem is that the image didn't install the openssl library.
Here is the error log:
{error_logger,{{2016,1,8},{1,22,10}},"Unable to load crypto library. Failed with error:~n"~p, ~s"~nOpenSSL might not be installed on this system.~n",[load_failed,"Failed to load NIF library: 'Error relocating /hellophoenix/lib/crypto-3.6.2/priv/lib/crypto.so: __memcpy_chk: symbol not found'"]}
Thank you very much for all your efforts!
This is my Dockerfile:
FROM alpine:3.3
RUN apk --update add erlang && rm -rf /var/cache/apk/*
CMD ["/bin/sh"]
This is the build result on AWS EC2 Ubuntu:
ubuntu@ip-172-31-30-16:~/kklepper/galpine/erlang$ sudo docker build -t kklepper/erlang .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM alpine:3.3
3.3: Pulling from library/alpine
4d06f2521e4f: Already exists
Digest: sha256:1849e75e25b5a005781b32e7ce0ec2892c85ef3d40d76861a6d3c721f1acc353
Status: Downloaded newer image for alpine:3.3
---> 70c557e50ed6
Step 2 : RUN apk --update add erlang && rm -rf /var/cache/apk/*
---> Running in d94b82b91d3f
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.3/main: No such file or directory
WARNING: Ignoring APKINDEX.5a59b88b.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.3/community: No such file or directory
WARNING: Ignoring APKINDEX.7c1f02d6.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
erlang (missing):
required by: world[erlang]
The command '/bin/sh -c apk --update add erlang && rm -rf /var/cache/apk/*' returned a non-zero code: 1
What did I do wrong? What can I do about it?
This is much better than my Ubuntu based container -- thank you for the work!
My question, as someone new to Elixir, is how does this integrate with Alchemist on Emacs? Can we just expose a port and have Alchemist connect to the process in there?
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples$ cd hello_phoenix/
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello_phoenix$ sudo docker build -t kklepper/hello_phoenix:alpine .
Sending build context to Docker daemon 243.2 kB
Step 1 : FROM msaraiva/erlang:18.1
---> a3f284987480
Step 2 : RUN apk --update add erlang-crypto erlang-sasl && rm -rf /var/cache/apk/*
---> Running in 0849f87e4ba6
fetch http://dl-4.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/2) Installing erlang-crypto (18.1-r5)
(2/2) Installing erlang-sasl (18.1-r5)
OK: 24 MiB in 20 packages
---> e5c049b0ebfe
Removing intermediate container 0849f87e4ba6
Step 3 : ENV APP_NAME hello_phoenix
---> Running in 5569fb9897d3
---> 35e986e9965b
Removing intermediate container 5569fb9897d3
Step 4 : ENV APP_VERSION "0.0.1"
---> Running in ad1d69b53a31
---> 3b252f2ab2ea
Removing intermediate container ad1d69b53a31
Step 5 : ENV PORT 4000
---> Running in 6ee818fc3ba3
---> 7faf684269cf
Removing intermediate container 6ee818fc3ba3
Step 6 : RUN mkdir -p /$APP_NAME
---> Running in 55cb511136df
---> a2e4ae1c442c
Removing intermediate container 55cb511136df
Step 7 : ADD rel/$APP_NAME/bin /$APP_NAME/bin
lstat rel/hello_phoenix/bin: no such file or directory
ubuntu@ip-172-31-30-16:~/msaraiva/docker-alpine-examples/hello_phoenix$ ls -la rel/
total 12
drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 23 15:03 .
drwxrwxr-x 8 ubuntu ubuntu 4096 Mar 23 15:03 ..
-rw-rw-r-- 1 ubuntu ubuntu 23 Mar 23 15:03 relx.config
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.