title: Docker Alpine executable binary not found even if in PATH
body: <p>I have an alpine running container which contains some binaries in <code>usr/local/bin</code></p>
  <p>When I <code>ls</code> the content of <code>usr/local/bin</code> I got this output :</p>
  <pre class="lang-sh prettyprint-override"><code>/usr/local/bin # ls
  dwg2SVG     dwg2dxf     dwgadd      dwgbmp      dwgfilter   dwggrep     dwglayers   dwgread     dwgrewrite  dwgwrite    dxf2dwg     dxfwrite
  </code></pre>
  <p>Which is what I expected.
  However if I execute one of these binaries by calling it I got a <code>not found</code> error from the shell :</p>
  <pre class="lang-sh prettyprint-override"><code>/usr/local/bin # dwg2dxf
  sh: dwgread: not found
  /usr/local/bin # ./dwg2dxf
  sh: ./dwgread: not found
  </code></pre>
  <p>I tested my <code>$PATH</code> which seems to be correct :</p>
  <pre class="lang-sh prettyprint-override"><code>/usr/local/bin # echo $PATH
  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  </code></pre>
  <p>How can I make those binaries callable or &quot;foundable&quot; ? Did I miss something in my Dockerfile build ?
  I suppose that there is something with the <code>ldconfig</code> command in alpine that went wrong but I'm not sure.</p>
  <p><strong>EDIT</strong></p>
  <p>As suggested in one answer here I executed the <code>file</code> command and here is the output :</p>
  <pre class="lang-sh prettyprint-override"><code>/usr/local/bin # file dwg2dxf
  dwgread: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=7835d4a42651a5fb7bdfa2bd8a76e40096bacb07, with debug_info, not stripped
  </code></pre>
  <p>Thoses binaries are from the <a href="https://github.com/LibreDWG/libredwg" rel="noreferrer">LibreDWG Official repository</a> as well as the first part of my Dockerfile. Here is the complete Dockerfile :</p>
  <pre><code># podman/docker build -t libredwg .
  ############################
  # STEP 1 build package from latest tar.xz
  ############################
  
  FROM python:3.7.7-buster AS extracting
  # libxml2-dev is broken so we need to compile it by our own
  ARG LIBXML2VER=2.9.9
  RUN apt-get update &amp;&amp; \
      apt-get install -y --no-install-recommends autoconf libtool swig texinfo \
              build-essential gcc libxml2 python3-libxml2 libpcre2-dev libpcre2-32-0 curl \
              libperl-dev libxml2-dev &amp;&amp; \
      mkdir libxmlInstall &amp;&amp; cd libxmlInstall &amp;&amp; \
      wget ftp://xmlsoft.org/libxml2/libxml2-$LIBXML2VER.tar.gz &amp;&amp; \
      tar xf libxml2-$LIBXML2VER.tar.gz &amp;&amp; \
      cd libxml2-$LIBXML2VER/ &amp;&amp; \
      ./configure &amp;&amp; \
      make &amp;&amp; \
      make install &amp;&amp; \
      cd /libxmlInstall &amp;&amp; \
      rm -rf gg libxml2-$LIBXML2VER.tar.gz libxml2-$LIBXML2VER
  WORKDIR /app
  RUN tarxz=`curl --silent 'https://ftp.gnu.org/gnu/libredwg/?C=M;O=D' | grep '.tar.xz&lt;' | \
           head -n1|sed -E 's/.*href=&quot;([^&quot;]+)&quot;.*/\1/'`; \
      echo &quot;latest release $tarxz&quot;; \
      curl --silent --output &quot;$tarxz&quot; https://ftp.gnu.org/gnu/libredwg/$tarxz &amp;&amp; \
      mkdir libredwg &amp;&amp; \
      tar -C libredwg --xz --strip-components 1 -xf &quot;$tarxz&quot; &amp;&amp; \
      rm &quot;$tarxz&quot; &amp;&amp; \
      cd libredwg &amp;&amp; \
      ./configure --disable-bindings --enable-release &amp;&amp; \
      make -j `nproc` &amp;&amp; \
      mkdir install &amp;&amp; \
      make install DESTDIR=&quot;$PWD/install&quot; &amp;&amp; \
      make check DOCKER=1 DESTDIR=&quot;$PWD/install&quot;
  
  ############################
  # STEP 2 install into stable-slim
  ############################
  
  # pull official base image
  FROM osgeo/gdal:alpine-normal-latest
  
  # set work directory
  WORKDIR /usr/src/app
  
  
  
  # set environment variables
  ENV PYTHONDONTWRITEBYTECODE 1
  ENV PYTHONUNBUFFERED 1
  
  # copy requirements file
  COPY ./requirements.txt /usr/src/app/requirements.txt
  
  # install dependencies
  RUN set -eux \
      &amp;&amp; apk add --no-cache --virtual .build-deps build-base \
          py3-pip libressl-dev libffi-dev gcc musl-dev python3-dev postgresql-dev\
      &amp;&amp; pip3 install --upgrade pip setuptools wheel \
      &amp;&amp; pip3 install -r /usr/src/app/requirements.txt \
      &amp;&amp; rm -rf /root/.cache/pip
  
  # Install libredwg binaries
  COPY --from=extracting /app/libredwg/install/usr/local/bin/* /usr/local/bin/
  COPY --from=extracting /app/libredwg/install/usr/local/include/* /usr/local/include/
  COPY --from=extracting /app/libredwg/install/usr/local/lib/* /usr/local/lib/
  COPY --from=extracting /app/libredwg/install/usr/local/share/* /usr/local/share/
  RUN ldconfig /usr/local/bin/
  RUN ldconfig /usr/local/include/
  RUN ldconfig /usr/local/lib/
  RUN ldconfig /usr/local/share/
  
  # copy project
  COPY . /usr/src/app/
  </code></pre>