hexpm / bob

The Builder
242 stars 60 forks source link

hexpm/elixir Ubuntu/Debian images don't support ICMP protocol while Alpine ones do #106

Open balena opened 2 years ago

balena commented 2 years ago

The test consists in performing the following commands:

$ docker run --rm -ti hexpm/elixir:1.13.2-erlang-24.2.1-ubuntu-focal-20211006 sh
# iex
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Interactive Elixir (1.13.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :socket.open(:inet, :raw, :icmp)
{:error, {:invalid, {:protocol, :icmp}}}

and repeating for each Debian/Ubuntu images available.

Then if you perform the same for Alpine Linux, it actually works:

$ docker run --rm -ti hexpm/elixir-arm64:1.13.2-erlang-24.2.1-alpine-3.15.0 sh
/ # iex
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Interactive Elixir (1.13.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :socket.open(:inet, :raw, :icmp)
{:ok, {:"$socket", #Reference<0.4054872251.4063100932.145697>}}

The problem seems to be related to some missing package at build time. Reference seems to be here: https://github.com/erlang/otp/blob/aa7f201ac2405ef6bf25d3111934f89dc3e23b73/erts/emulator/nifs/common/socket_nif.c#L169. The definition HAVE_LINUX_ERRQUEUE_H seems to be missing during build time.

josevalim commented 2 years ago

Do you know which package is missing? If so, could you please send a PR?

aschiavon91 commented 1 year ago

I did some tests and looks like we're missing netbase package to get it work, but I can't reproduce the error in all debian/ubuntu images, for example, in the image hexpm/erlang:22.2-ubuntu-bionic-20200219 it works

lbellomo commented 3 days ago

I did some research and aschiavon91 is right in the previous comment: the netbase dependency is missing in the final erlang img. For example to test it on several images:

# debian-bookworm
$ docker run -i -a stdout hexpm/elixir:1.15.8-erlang-25.3.2.9-debian-bookworm-20240904 sh -c 'echo ":socket.open(:inet, :raw, :icmp)" | iex'
iex(1)> {:error, {:invalid, {:protocol, :icmp}}}

# debian-bookworm with 'netbase'
$ docker run -i -a stdout hexpm/elixir:1.15.8-erlang-25.3.2.9-debian-bookworm-20240904 sh -c 'apt update && apt install netbase && echo ":socket.open(:inet, :raw, :icmp)" | iex'
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
[...]
iex(1)> {:ok, {:"$socket", #Reference<0.3787441770.2561802246.469>}}

I also test it for the following img (trying to grab one of each type) and it works on all of them when the package is installed:

I did not test it for arm64 and I have doubts here. It should work, but it would be good to confirm it.

lbellomo commented 2 days ago

I was able to test the images for the arm64 architecture. It also works when installing the netbase package. Now I do a PR to add the netbase package to the final step of the erlang dockerfiles.