8

I've set up a simple docker container with Alpine and a tool called bowtie2. When I try to run bowtie2-align-s, I get this error:

sh: ./bowtie2-align-s: not found

However, ls tells me that the file is there. I installed bowtie2 from a Linux binary distribution. How would I tell if that distribution is compatible with Alpine Linux? I'm running docker 17.09.0-ce on Ubuntu 16.04.

Here's the full Dockerfile:

FROM alpine:3.6

ENV BOWTIE2_VERSION 2.2.8

RUN apk add --no-cache \
        perl \
        wget \
        openssl \
        ca-certificates \
        strace \
    && 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 test it like this:

$ sudo docker run -it --rm --security-opt seccomp:unconfined bowtie2-bin sh
/ # /usr/local/bowtie2-2.2.8/bowtie2-align-s --version
sh: /usr/local/bowtie2-2.2.8/bowtie2-align-s: not found
/ # ls -l /usr/local/bowtie2-2.2.8/bowtie2-align-s
-rwxr-xr-x    1 root     root      11600541 Nov 15 18:49 /usr/local/bowtie2-2.2.8/bowtie2-align-s
/ # strace -v -s 1000 /usr/local/bowtie2-2.2.8/bowtie2-align-s --version
execve("/usr/local/bowtie2-2.2.8/bowtie2-align-s", ["/usr/local/bowtie2-2.2.8/bowtie2-align-s", "--version"], ["HOSTNAME=a72609479c9a", "SHLVL=1", "HOME=/root", "TERM=xterm", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "BOWTIE2_VERSION=2.2.8", "PWD=/"]) = -1 ENOENT (No such file or directory)
writev(2, [{iov_base="strace: exec: No such file or directory", iov_len=39}, {iov_base="\n", iov_len=1}], 2strace: exec: No such file or directory
) = 40
writev(2, [{iov_base="", iov_len=0}, {iov_base=NULL, iov_len=0}], 2) = 0
getpid()                                = 11
exit_group(1)                           = ?
+++ exited with 1 +++
/ #

I run docker with unconfined access to allow strace to run. You can see that ls finds the file, but sh doesn't seem to. strace doesn't seem to show any other files being accessed, so what is going on?

Don Kirkby
  • 1,154
  • 3
  • 10
  • 23

1 Answers1

10

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.

Don Kirkby
  • 1,154
  • 3
  • 10
  • 23