romenigld

romenigld

Docker run Error loading shared library libstdc++.so.6 and libgcc_s.so.1

I am trying to run a deploy with docker and I successfully runned with this command:

docker build -t romenigld/blog-prod .

but when I tried to do with this command:

docker run --env-file .env -p 8080:4000 romenigld/blog-prod

I`m getting this error:

Error loading shared library libstdc++.so.6: No such file or directory (needed by /app/erts-12.0.2/bin/beam.smp)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /app/erts-12.0.2/bin/beam.smp)
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_begin_catch: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt24__throw_out_of_range_fmtPKcz: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _Znwm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt20__throw_length_errorPKc: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_guard_release: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __popcountdi2: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt17__throw_bad_allocv: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_end_catch: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_guard_acquire: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEmmm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt19__throw_logic_errorPKc: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_rethrow: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _Unwind_Resume: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZdlPvm: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __cxa_pure_virtual: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: _ZTVN10__cxxabiv121__vmi_class_type_infoE: symbol not found
Error relocating /app/erts-12.0.2/bin/beam.smp: __gxx_personality_v0: symbol not found

My Dockerfile:

FROM elixir:alpine AS build

# install build dependencies
RUN apk add --no-cache build-base npm git python3

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# set build ENV
ENV MIX_ENV=prod

# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile

# build assets
COPY assets/package.json assets/package-lock.json ./assets/
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error

COPY priv priv
COPY assets assets
RUN npm run --prefix ./assets deploy
RUN mix phx.digest

# compile and build release
COPY lib lib
RUN mix do compile, release

# prepare release image
FROM alpine:3.9 AS app

RUN apk add --no-cache openssl ncurses-libs

WORKDIR /app

RUN chown nobody:nobody /app

USER nobody:nobody

COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/blog ./

ENV HOME=/app

CMD ["bin/blog", "start"]

my docker_dev_start.sh:

mix ecto.drop
mix ecto.setup
exec mix phx.server

my docker-compose.yml:

version: "3"
services:
  app:
    restart: on-failure # vai restartar na falha(outras opções [no, always, unless-stopped(quando força a ação)])
    build:
      context: .
      dockerfile: Dockerfile.dev
    command: /bin/sh docker_dev_start.sh
    ports:
      - "8080:4000"
    depends_on:
      - db
    links:
      - db
  db:
    restart: always
    image: postgres
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
    ports:
      - "5432:5432"

Most Liked

joshdcuneo

joshdcuneo

It looks like a missing runtime dependency in your final image. Try changing RUN apk add --no-cache openssl ncurses-libs to RUN apk add --no-cache openssl ncurses-libs libstdc++.

LostKobrakai

LostKobrakai

The beam has native runtime dependencies and OTP 24 added libc as runtime dependency to support the JIT. With that change it seems like bare alpine:3.9 no longer brings all the required runtime dependencies. You’ll need to make sure that all of those those are present in the app container.

romenigld

romenigld

I asked in stackoverflow.
And put this:


# prepare release image 
FROM alpine:3.14 AS app 
RUN apk upgrade --no-cache && \ 
apk add --no-cache postgresql-client bash openssl libgcc libstdc++ ncurses-libs

and now worked for me. Thank you guys!

tejpochiraju

tejpochiraju

Can confirm that this change seems to be needed ever since the elixir:alpine image used to build the app moved to Elixir 1.12.

romenigld

romenigld

Hello @frankely I quit the postgresql-client because I installed in other way.
My final Dockerfile was this:

FROM elixir:alpine AS build

# install build dependencies
RUN apk add --no-cache build-base npm git python3

# prepare build dir
WORKDIR /app

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# set build ENV
ENV MIX_ENV=prod

# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix do deps.get, deps.compile

# build assets
COPY assets/package.json assets/package-lock.json ./assets/
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error

COPY priv priv
COPY assets assets
RUN npm run --prefix ./assets deploy
RUN mix phx.digest

# compile and build release
COPY lib lib
RUN mix do compile, release

# prepare release image
FROM alpine AS app

# RUN apk add --no-cache openssl ncurses-libs
RUN apk upgrade --no-cache && \
    apk add --no-cache bash openssl libgcc libstdc++ ncurses-libs

WORKDIR /app

RUN chown nobody:nobody /app

USER nobody:nobody

COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/blog ./

ENV HOME=/app

CMD ["bin/blog", "start"]

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement