dockeralpine-linuxrar

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:

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.

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.

Why is this happening?


Solution

  • Alpine is built using 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.

    Common ways to solve this include either (a) compile the code yourself or (b) install a version that has been built elsewhere for Alpine. I don't believe either of these is going to be an option for Rar.

    Your best bet is just to replace Alpine as your base image with something (really, almost anything) else (debian, ubuntu, fedora, centos, etc).

    (Note that if you just need to extract Rar archives, you can simply apk add unrar under Alpine).