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

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement