gpt4 book ai didi

node.js - Docker 容器中的 Alpine linux => `env: can' t 执行 'node' : No such file or directory`

转载 作者:搜寻专家 更新时间:2023-10-31 22:58:54 47 4
gpt4 key购买 nike

我正在像这样在 Alpine linux 容器中安装 Node.js 版本 8:

RUN apk add --no-cache wget

RUN wget http://nodejs.org/dist/v8.1.1/node-v8.1.1-linux-x64.tar.gz
RUN sudo tar -C /usr/local --strip-components 1 -xzf node-v8.1.1-linux-x64.tar.gz

RUN ls -l /usr/local/bin/node
RUN ls -l /usr/local/bin/npm

RUN ln -s /usr/local/bin/node /usr/bin/node
RUN ln -s /usr/local/bin/npm /usr/bin/npm

ENV PATH "/usr/local/bin:${PATH}"
RUN echo "PATH env variable => '$PATH'"

/usr/local/bin/node/usr/local/bin/npm 存在,并且 npm 不知何故确实在命令行中被识别。但是对于 Node 可执行文件,我收到此错误:

Step 23/53 : RUN npm cache clean -f
---> Running in 8bbc96b88935
env: can't execute 'node': No such file or directory

我可以确认 $PATH 变量包括两者

/usr/local/bin
/usr/bin

例如:

Step 19/53 : RUN echo "PATH env variable => '$PATH'"
---> Running in c5227e6e3db0
PATH env variable => '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

那么为什么 env 找不到 Node 可执行文件?太奇怪了。

这是一个线索:

Step 10/52 : RUN ldd /usr/local/bin/node
---> Running in db210653f0ed
/lib64/ld-linux-x86-64.so.2 (0x7fefae36b000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7fefae36b000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7fefae36b000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fefae36b000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7fefae36b000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fefae36b000)
Error loading shared library libstdc++.so.6: No such file or directory (needed by /usr/local/bin/node)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /usr/local/bin/node)
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE9pbackfailEi: symbol not found
Error relocating /usr/local/bin/node: _ZNSt13runtime_errorC2ERKSs: symbol not found
Error relocating /usr/local/bin/node: _ZSt19__throw_logic_errorPKc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt9exceptionD2Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSsC1ERKSs: symbol not found
Error relocating /usr/local/bin/node: _ZSt17__throw_bad_allocv: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6appendEmc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE6xsgetnEPcl: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertIyEERSoT_: symbol not found
Error relocating /usr/local/bin/node: _ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEED1Ev: symbol not found
Error relocating /usr/local/bin/node: _Znwm: symbol not found
Error relocating /usr/local/bin/node: _ZNSt11logic_errorC2ERKSs: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6assignEPKc: symbol not found
Error relocating /usr/local/bin/node: _ZTv0_n24_NSoD1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt13basic_filebufIcSt11char_traitsIcEE5closeEv: symbol not found
Error relocating /usr/local/bin/node: _ZNKSt13runtime_error4whatEv: symbol not found
Error relocating /usr/local/bin/node: _ZTv0_n24_NSt14basic_ofstreamIcSt11char_traitsIcEED0Ev: symbol not found
Error relocating /usr/local/bin/node: __isinf: symbol not found
Error relocating /usr/local/bin/node: __cxa_demangle: symbol not found
Error relocating /usr/local/bin/node: _ZNSs9push_backEc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt9basic_iosIcSt11char_traitsIcEE7copyfmtERKS2_: symbol not found
Error relocating /usr/local/bin/node: _ZNSolsEi: symbol not found
Error relocating /usr/local/bin/node: _ZSt16__throw_bad_castv: symbol not found
Error relocating /usr/local/bin/node: __cxa_guard_acquire: symbol not found
Error relocating /usr/local/bin/node: _ZNKSs4findEcm: symbol not found
Error relocating /usr/local/bin/node: _ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E: symbol not found
Error relocating /usr/local/bin/node: _ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_ES4_: symbol not found
Error relocating /usr/local/bin/node: _ZdaPv: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertIlEERSoT_: symbol not found
Error relocating /usr/local/bin/node: __cxa_allocate_exception: symbol not found
Error relocating /usr/local/bin/node: backtrace_symbols: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertIbEERSoT_: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6resizeEmc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15__exception_ptr13exception_ptrC1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt13runtime_errorD2Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNKSt14error_category10equivalentERKSt10error_codei: symbol not found
Error relocating /usr/local/bin/node: _ZNSs12_M_leak_hardEv: symbol not found
Error relocating /usr/local/bin/node: _ZNKSs17find_first_not_ofEPKcmm: symbol not found
Error relocating /usr/local/bin/node: _Znam: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertIPKvEERSoT_: symbol not found
Error relocating /usr/local/bin/node: _ZNKSt5ctypeIcE13_M_widen_initEv: symbol not found
Error relocating /usr/local/bin/node: _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base: symbol not found
Error relocating /usr/local/bin/node: _ZNSo5writeEPKcl: symbol not found
Error relocating /usr/local/bin/node: _ZNSo5flushEv: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertImEERSoT_: symbol not found
Error relocating /usr/local/bin/node: _ZNSt12__basic_fileIcED1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZTv0_n24_NSoD0Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv: symbol not found
Error relocating /usr/local/bin/node: _ZNSsC1EPKcmRKSaIcE: symbol not found
Error relocating /usr/local/bin/node: _ZdlPv: symbol not found
Error relocating /usr/local/bin/node: _ZNSo3putEc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE7seekoffElSt12_Ios_SeekdirSt13_Ios_Openmode: symbol not found
Error relocating /usr/local/bin/node: _ZTv0_n24_NSt14basic_ofstreamIcSt11char_traitsIcEED1Ev: symbol not found
Error relocating /usr/local/bin/node: __cxa_guard_release: symbol not found
Error relocating /usr/local/bin/node: _ZNSs9_M_mutateEmmm: symbol not found
Error relocating /usr/local/bin/node: _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode: symbol not found
Error relocating /usr/local/bin/node: _ZNKSs5rfindEcm: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE7seekposESt4fposI11__mbstate_tESt13_Ios_Openmode: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6appendEPKcm: symbol not found
Error relocating /usr/local/bin/node: __gxx_personality_v0: symbol not found
Error relocating /usr/local/bin/node: _ZNSs4swapERSs: symbol not found
Error relocating /usr/local/bin/node: _ZNSoD0Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSsC1EmcRKSaIcE: symbol not found
Error relocating /usr/local/bin/node: _ZSt20__throw_length_errorPKc: symbol not found
Error relocating /usr/local/bin/node: _ZSt20__throw_out_of_rangePKc: symbol not found
Error relocating /usr/local/bin/node: __cxa_throw: symbol not found
Error relocating /usr/local/bin/node: _ZNSt11logic_errorD2Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_stringbufIcSt11char_traitsIcESaIcEE7_M_syncEPcmm: symbol not found
Error relocating /usr/local/bin/node: _Unwind_Resume: symbol not found
Error relocating /usr/local/bin/node: __popcountdi2: symbol not found
Error relocating /usr/local/bin/node: _ZNSt8ios_base4InitD1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6appendEPKc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt9basic_iosIcSt11char_traitsIcEE5rdbufEPSt15basic_streambufIcS1_E: symbol not found
Error relocating /usr/local/bin/node: __register_atfork: symbol not found
Error relocating /usr/local/bin/node: __isnan: symbol not found
Error relocating /usr/local/bin/node: _ZNKSt14error_category23default_error_conditionEi: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE9showmanycEv: symbol not found
Error relocating /usr/local/bin/node: _ZNSt18condition_variableD1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSs4_Rep9_S_createEmmRKSaIcE: symbol not found
Error relocating /usr/local/bin/node: _ZNSs14_M_replace_auxEmmmc: symbol not found
Error relocating /usr/local/bin/node: _ZNSt8ios_baseD2Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6insertEmPKcm: symbol not found
Error relocating /usr/local/bin/node: _ZSt21__throw_runtime_errorPKc: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertIdEERSoT_: symbol not found
Error relocating /usr/local/bin/node: _ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt6localeC1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6assignEPKcm: symbol not found
Error relocating /usr/local/bin/node: _ZNSs4_Rep10_M_disposeERKSaIcE: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6assignERKSs: symbol not found
Error relocating /usr/local/bin/node: _ZNSs6appendERKSs: symbol not found
Error relocating /usr/local/bin/node: _ZNSt13basic_filebufIcSt11char_traitsIcEEC1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1ESt13_Ios_Openmode: symbol not found
Error relocating /usr/local/bin/node: _ZNKSs4findEPKcmm: symbol not found
Error relocating /usr/local/bin/node: _ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE9underflowEv: symbol not found
Error relocating /usr/local/bin/node: __cxa_free_exception: symbol not found
Error relocating /usr/local/bin/node: _ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15__exception_ptr13exception_ptrD1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSoD1Ev: symbol not found
Error relocating /usr/local/bin/node: __cxa_pure_virtual: symbol not found
Error relocating /usr/local/bin/node: _ZNSt14basic_ofstreamIcSt11char_traitsIcEED0Ev: symbol not found
Error relocating /usr/local/bin/node: __dynamic_cast: symbol not found
Error relocating /usr/local/bin/node: _ZNSt13basic_filebufIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode: symbol not found
Error relocating /usr/local/bin/node: _ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base: symbol not found
Error relocating /usr/local/bin/node: _ZNSs4_Rep10_M_destroyERKSaIcE: symbol not found
Error relocating /usr/local/bin/node: _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l: symbol not found
Error relocating /usr/local/bin/node: _ZNKSt14error_category10equivalentEiRKSt15error_condition: symbol not found
Error relocating /usr/local/bin/node: _ZNSt8ios_baseC2Ev: symbol not found
Error relocating /usr/local/bin/node: _ZNSt6localeD1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_: symbol not found
Error relocating /usr/local/bin/node: _ZNSt8ios_base4InitC1Ev: symbol not found
Error relocating /usr/local/bin/node: _ZnwmRKSt9nothrow_t: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE5uflowEv: symbol not found
Error relocating /usr/local/bin/node: _ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base: symbol not found
Error relocating /usr/local/bin/node: _ZNSsC1ERKSsmm: symbol not found
Error relocating /usr/local/bin/node: _ZNKSs7compareEPKc: symbol not found
Error relocating /usr/local/bin/node: _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_: symbol not found
Error relocating /usr/local/bin/node: _ZdlPvRKSt9nothrow_t: symbol not found
Error relocating /usr/local/bin/node: _ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate: symbol not found
Error relocating /usr/local/bin/node: _ZNSsD1Ev: symbol not found
Error relocating /usr/local/bin/node: backtrace: symbol not found
Error relocating /usr/local/bin/node: _ZNSsC1EPKcRKSaIcE: symbol not found
Error relocating /usr/local/bin/node: _ZNSt15basic_streambufIcSt11char_traitsIcEE6setbufEPcl: symbol not found
Error relocating /usr/local/bin/node: _ZNSo9_M_insertIxEERSoT_: symbol not found
Error relocating /usr/local/bin/node: _ZNSs7reserveEm: symbol not found
Error relocating /usr/local/bin/node: _ZTISt14error_category: symbol not found
Error relocating /usr/local/bin/node: _ZTISt11logic_error: symbol not found
Error relocating /usr/local/bin/node: _ZTISt9exception: symbol not found
Error relocating /usr/local/bin/node: _ZTISt13runtime_error: symbol not found
Error relocating /usr/local/bin/node: _ZNSs4_Rep20_S_empty_rep_storageE: symbol not found
Error relocating /usr/local/bin/node: _ZNSt8__detail12__prime_listE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt14error_category: symbol not found
Error relocating /usr/local/bin/node: _ZSt7nothrow: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt15basic_stringbufIcSt11char_traitsIcESaIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTVN10__cxxabiv121__vmi_class_type_infoE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt19basic_ostringstreamIcSt11char_traitsIcESaIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTTSt14basic_ofstreamIcSt11char_traitsIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTVN10__cxxabiv117__class_type_infoE: symbol not found
Error relocating /usr/local/bin/node: _ZTVN10__cxxabiv120__si_class_type_infoE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt15basic_streambufIcSt11char_traitsIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt14basic_ofstreamIcSt11char_traitsIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt9basic_iosIcSt11char_traitsIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt18basic_stringstreamIcSt11char_traitsIcESaIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTVSt13basic_filebufIcSt11char_traitsIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTTSt18basic_stringstreamIcSt11char_traitsIcESaIcEE: symbol not found
Error relocating /usr/local/bin/node: _ZTTSt19basic_ostringstreamIcSt11char_traitsIcESaIcEE: symbol not found
The command '/bin/sh -c ldd /usr/local/bin/node' returned a non-zero code: 127

运行这个新调用后:

RUN apk add --no-cache libstdc++ && apk add --no-cache libgcc

我仍然遇到错误:

Step 12/54 : RUN ldd /usr/local/bin/node
---> Running in deecef947d0b
/lib64/ld-linux-x86-64.so.2 (0x7f9266dee000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f9266dee000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7f9266dee000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f9266a9c000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f9266dee000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f926688a000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f9266dee000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f9266dee000)
Error relocating /usr/local/bin/node: __isinf: symbol not found
Error relocating /usr/local/bin/node: backtrace_symbols: symbol not found
Error relocating /usr/local/bin/node: __register_atfork: symbol not found
Error relocating /usr/local/bin/node: __isnan: symbol not found
Error relocating /usr/local/bin/node: backtrace: symbol not found

最佳答案

Alpine 发行版基于名为 musl-libc 的 libc 变体。 .您正在安装的 node 二进制文件是针对 glibc 编译的,因为大多数(所有?)其他标准发行版使用更常用的 glibc 标准库。

一个选择是将 glibc 添加到您的 alpine 发行版基础,然后如果您确实无法针对 musl-libc 编译 Node ,您可以允许您添加的 glibc 支持处理不匹配。还有其他stackoverflow answers其中提供了有关如何执行此操作的详细信息。

但是,我认为最好的情况是您使用针对 Alpine 的 musl-libc 构建的 Node 二进制文件。这是官方 Node 图像处理 alpine 标签变体的方式。您可以在 official Node 12.4.0 release Dockerfile 中看到他们是如何做到这一点的。对于 Node 的 Alpine 变体。当然,与下载预构建的二进制文件相比,构建 Node 的构建时间会更长,但它会简化尝试将 glibc 支持强行引入 Alpine 的任何复杂情况。

关于node.js - Docker 容器中的 Alpine linux => `env: can' t 执行 'node' : No such file or directory`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45973481/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com