简体   繁体   English

如何在基于 Alpine 的容器中安装 rar?

[英]How do I install rar in a Alpine based container?

A program in the container needs rar (in addition to unrar ), I used the following commands to install it to /usr/bin :容器中的一个程序需要rar (除了unrar ),我使用以下命令将其安装到/usr/bin

curl https://www.rarlab.com/rar/rarlinux-x64-6.0.b1.tar.gz | tar -xzvf - -C /tmp/
cp -rfp /tmp/rar/rar /usr/bin/rar

Now /usr/bin/rar exist and has 755 permission, and /usr/bin is in $PATH , but when I run rar -v or /usr/bin/rar , it outputs ash: rar: not found and ash: /usr/bin/rar: not found respectively.现在/usr/bin/rar存在并且具有 755 权限,并且/usr/bin$PATH ,但是当我运行rar -v/usr/bin/rar ,它输出ash: rar: not foundash: /usr/bin/rar: not found分别ash: /usr/bin/rar: not found

I got the same result with make and make install in /tmp/rar which after it copy rar and unrar into /usr/local/bin , which is also in $PATH .我在/tmp/rar使用makemake install得到了相同的结果,然后将rarunrar复制到/usr/local/bin ,后者也在$PATH

Why is this happening?为什么会这样?

Alpine is built using musl-libc . Alpine 是使用musl-libc构建的。 Software compiled against the more common glibc will often not run in this environment because it can't find the expected dynamic loader.针对更常见的glibc编译的软件通常不会在这种环境中运行,因为它找不到预期的动态加载程序。

Common ways to solve this include either (a) compile the code yourself or (b) install a version that has been built elsewhere for Alpine.解决此问题的常用方法包括 (a) 自己编译代码或 (b) 安装已在别处为 Alpine 构建的版本。 I don't believe either of these is going to be an option for Rar.我不相信这些都将成为 Rar 的选择。

Your best bet is just to replace Alpine as your base image with something (really, almost anything) else (debian, ubuntu, fedora, centos, etc).最好的办法就是用其他东西(实际上,几乎任何东西)(debian、ubuntu、fedora、centos 等)替换 Alpine 作为你的基本映像。

(Note that if you just need to extract Rar archives, you can simply apk install unrar under Alpine). (注意,如果你只需要解压 Rar 压缩包,你可以在 Alpine 下简单地apk install unrar )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM