Alpine shell can't find file in docker

Solution 1:

Thanks to BMitch's comment, I found the answer. I needed the libc6-compat package for GNU libc compatibility. Here's the fixed version of the docker file:

FROM alpine:3.6

ENV BOWTIE2_VERSION 2.2.8

RUN apk add --no-cache \
        perl \
        wget \
        openssl \
        ca-certificates \
        libc6-compat \
        libstdc++ \
    && wget https://downloads.sourceforge.net/project/bowtie-bio/bowtie2/$BOWTIE2_VERSION/bowtie2-$BOWTIE2_VERSION-linux-x86_64.zip \
    && unzip -d /usr/local bowtie2-$BOWTIE2_VERSION-linux-x86_64.zip \
    && rm bowtie2-$BOWTIE2_VERSION-linux-x86_64.zip

I also got it working when I built bowtie2 from source, so I think I'll go with that. I'm not sure how reliable the compatibility package is.

If you want all the details, I had to install the file package to follow BMitch's suggestion:

$ sudo docker run --rm -it bowtie2-bin sh
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-201-g6289c8472a [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-203-g6070fe8ac2 [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8438 distinct packages available
/ # apk add file
(1/2) Installing libmagic (5.32-r0)
(2/2) Installing file (5.32-r0)
Executing busybox-1.26.2-r7.trigger
OK: 50 MiB in 21 packages
/ # file /usr/local/bowtie2-2.2.8/bowtie2-align-s
/usr/local/bowtie2-2.2.8/bowtie2-align-s: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.9, with debug_info, not stripped

The interpreter interpreter /lib64/ld-linux-x86-64.so.2 looked suspicious to me, and Alpine Linux doesn't have a /lib64 folder. A little searching found a related discussion:

The binary you try to run is linked against GNU libc so it will not work, just like binaries compiled for windows or OSX will not work.

That said, musl libc provides partial GNU libc compatibility, which means that some binaries will actually work, even if there are no guarantee. Try apk add libc6-compat. It may or may not work.

I tried that, and found that I also needed the libstdc++ package. Now it works well enough to report the version number.