docker 加载共享库libstdc++.so.6和libgcc_s.so.1时出错

rlcwz9us  于 2022-11-22  发布在  Docker
关注(0)|答案(1)|浏览(271)

我尝试使用Docker运行部署,并且使用以下命令成功运行:
docker build -t romenigld/blog-prod .
但当我尝试执行以下命令时:
docker run --env-file .env -p 8080:4000 romenigld/blog-prod
我得到这个错误:

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

我的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"]

我的docker_dev_start.sh

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

我的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"
q1qsirdb

q1qsirdb1#

根据您部署的内容,像crypto(phoenix使用crypto)这样的包使用共享库来实现功能。

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

相关问题