c0b / docker-elixir

Official Docker image for Elixir :whale: :turtle: :rocket:

Home Page:http://elixir-lang.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenSSL might not be installed on this system error

carlo-colombo opened this issue · comments

Using tag 1.8.1-alpine of the image I have this error on startup

[load_failed,"Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /opt/app/lib/crypto-4.4/priv/lib/crypto.so)'","OpenSSL might not be installed on this system.\n"]
"Unable to load crypto library. Failed with error:~n\"~p, ~s\"~n~s"
{error_logger,error_msg}
#{label=>{proc_lib,crash},report=>[[{initial_call,{supervisor,kernel,['Argument__1']}},{pid,<0.1099.0>},{registered_name,[]},{error_info,{exit,{on_load_function_failed,crypto},[{init,run_on_load_handlers,0,[]},{kernel,init,1,[{file,"kernel.erl"},{line,212}]},{supervisor,init,1,[{file,"supervisor.erl"},{line,295}]},{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}},{ancestors,[kernel_sup,<0.1073.0>]},{message_queue_len,0},{messages,[]},{links,[<0.1075.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,376},{stack_size,27},{reductions,273}],[]]}
#{label=>{supervisor,start_error},report=>[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,{on_load_function_failed,crypto}},{offender,[{pid,undefined},{id,kernel_safe_sup},{mfargs,{supervisor,start_link,[{local,kernel_safe_sup},kernel,safe]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]}]}
#{label=>{proc_lib,crash},report=>[[{initial_call,{application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}},{pid,<0.1072.0>},{registered_name,[]},{error_info,{exit,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,crypto}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,138}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,249}]}]}},{ancestors,[<0.1071.0>]},{message_queue_len,1},{messages,[{'EXIT',<0.1073.0>,normal}]},{links,[<0.1071.0>,<0.1069.0>]},{dictionary,[]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,27},{reductions,193}],[]]}
#{label=>{application_controller,exit},report=>[{application,kernel},{exited,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,crypto}}},{kernel,start,[normal,[]]}}},{type,permanent}]}
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,crypto}}},{kernel,start,[normal,[]]}}}"}
    args:     format:     label: 2019-02-06 22:35:52.269014 crash_report        2019-02-06 22:35:52.269078 supervisor_report   2019-02-06 22:35:53.294613 crash_report        2019-02-06 22:35:53.330099 std_info            Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,crypto}}},{kernel,start,[normal,[]]}}})

Crash dump is being written to: erl_crash.dump...done

Version 1.8.0 is fine instead

commented

how does it startup? are you getting the same 1.8.1-alpine image (by sha256) ?

$ docker image pull elixir:1.8.1-alpine
1.8.1-alpine: Pulling from library/elixir
Digest: sha256:a8caf29888c7d2ba30fdebafde06505278725ba599c87b2c64da37de87f80cd3
Status: Downloaded newer image for elixir:1.8.1-alpine
$ docker container run -it --rm elixir:1.8.1-alpine sh
/ # iex --app crypto --app inets --app ssl
Erlang/OTP 21 [erts-10.2.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.8.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Application.started_applications
[
  {:ssl, 'Erlang/OTP SSL application', '9.1.2'},
  {:public_key, 'Public key infrastructure', '1.6.4'},
  {:asn1, 'The Erlang ASN1 compiler version 5.0.8', '5.0.8'},
  {:inets, 'INETS  CXC 138 49', '7.0.5'},
  {:crypto, 'CRYPTO', '4.4'},
  {:logger, 'logger', '1.8.1'},
  {:iex, 'iex', '1.8.1'},
  {:elixir, 'elixir', '1.8.1'},
  {:compiler, 'ERTS  CXC 138 10', '7.3.1'},
  {:stdlib, 'ERTS  CXC 138 10', '3.7'},
  {:kernel, 'ERTS  CXC 138 10', '6.2'}
]
iex(2)> :httpc.request 'https://nghttp2.org/httpbin/get'
{:ok,
 {{'HTTP/1.1', 200, 'OK'},
  [
    {'connection', 'close'},
    {'date', 'Thu, 07 Feb 2019 06:52:24 GMT'},
    {'via', '1.1 nghttpx'},
    {'server', 'nghttpx'},
    {'content-length', '181'},
    {'content-type', 'application/json'},
    {'access-control-allow-origin', '*'},
    {'access-control-allow-credentials', 'true'},
    {'x-backend-header-rtt', '0.006974999999999953'},
    {'strict-transport-security', 'max-age=31536000'},
    {'x-frame-options', 'SAMEORIGIN'},
    {'x-xss-protection', '1; mode=block'},
    {'x-content-type-options', 'nosniff'}
  ],
  '{\n  "args": {}, \n  "headers": {\n    "Content-Length": "0", \n    "Host": "nghttp2.org", \n    "Te": ""\n  }, \n  "origin": "xx.xx.xx.98", \n  "url": "https://nghttp2.org/httpbin/get"\n}\n'}}
iex(2)> 
User switch command
 --> q
/ # find / -xdev -name libcrypto.so.1.1
/usr/lib/libcrypto.so.1.1
/lib/libcrypto.so.1.1

Same issue here. I just checked, it's the same 1.8.1-alpine image:

# docker inspect --format='{{index .RepoDigests 0}}' elixir:1.8.1-alpine
elixir@sha256:a8caf29888c7d2ba30fdebafde06505278725ba599c87b2c64da37de87f80cd3
web_1     | 12:13:39.125 [error] Unable to load crypto library. Failed with error:
web_1     | ":load_failed, Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /opt/app/lib/crypto-4.4/priv/lib/crypto.so)'"
web_1     | OpenSSL might not be installed on this system.
web_1     |
web_1     | 12:13:39.140 [warn] The on_load function for module crypto returned:
web_1     | {:error, {:load_failed, 'Failed to load NIF library: \'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /opt/app/lib/crypto-4.4/priv/lib/crypto.so)\''}}
web_1     |
web_1     | ▸  Evaluation failed with: function :crypto.strong_rand_bytes/1 is undefined (module :crypto is not available)
web_1     | ▸      (crypto) :crypto.strong_rand_bytes(16)
web_1     | ▸      (ecto) lib/ecto/uuid.ex:165: Ecto.UUID.bingenerate/0
web_1     | ▸      (ecto) lib/ecto/uuid.ex:156: Ecto.UUID.generate/0
web_1     | ▸      (elixir) lib/map.ex:362: Map.put_new_lazy/3
web_1     | ▸      (ecto) lib/ecto/embedded.ex:111: Ecto.Embedded.to_struct/4
web_1     | ▸      (ecto) lib/ecto/embedded.ex:62: anonymous fn/6 in Ecto.Embedded.prepare/5
web_1     | ▸      (stdlib) maps.erl:257: :maps.fold_1/3
web_1     | ▸      (ecto) lib/ecto/repo/schema.ex:209: anonymous fn/15 in Ecto.Repo.Schema.do_insert/3

Using 1.8.0-alpine and below (just tried 1.7.1-alpine) works without issues.

Same issue here. 1.7.4-alpine

12:42:14.918 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /opt/app/lib/crypto-4.4/priv/lib/crypto.so)'"
OpenSSL might not be installed on this system.

12:42:14.932 [error] Unable to load crypto library. Failed with error:
":load_failed, Failed to load NIF library: 'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /opt/app/lib/crypto-4.4/priv/lib/crypto.so)'"
OpenSSL might not be installed on this system.

12:42:14.933 [warn] The on_load function for module crypto returned:
{:error, {:load_failed, 'Failed to load NIF library: \'Error loading shared library libcrypto.so.1.1: No such file or directory (needed by /opt/app/lib/crypto-4.4/priv/lib/crypto.so)\''}}

erlang:21-alpine have updated its base alpine version to 3.9 7 days ago. Would that be the reason cause this issue?

You should make your the alpine version you used in the container to build the artifacts matches with the release container.

commented

yes, it is that situation of x (number of os) * y (number of erlang-version) * z (number of elixir versions), and now the alpine versions add another dimension of libssl versions,

it matters of how many users want it? and how many dev(s) willing to contribute a PR; we need a balance between how many variants are useful and how much maintenance effort is worth the number of users

Yes this was due to alpine 3.8's openssl which otp didn't like (I contributed the patch for the erlang image).
This can be closed ;)

This appears to be an issue with 1.9-alpine as well, and it doesn't look like there is a 1.9-otp-22-alpine version available?

Edit: Looks like the 1.9 image is based on otp-22. I'm still seeing Error loading shared library libcrypto.so.1.1 though. Investigating.

Edit 2: After digging a bit deeper, turns out we were building the app with this image, but deploying the release with https://hub.docker.com/r/pentacent/alpine-erlang-base/dockerfile, which is still based on alpine 3.7. Which caused problems at runtime. Swapped over to using this image for the release as well and things started working as they should.