title: Why can't I run a C program built on alpine on ubuntu?
body: <p>I compiled a simple hello world C program inside of an alpine linux container and copied it onto my ubuntu host. To my surprise, I am not able to run the binary on my ubuntu host. Instead, I get the following error when I try to execute the program.</p>
  
  <pre><code>$ /bin/bash ./hello
  $ ./hello: ./hello: cannot execute binary file
  </code></pre>
  
  <p>Why can't I run my program that was compiled on alpine on ubuntu?</p>
  
  <p><strong>UPDATE</strong>
  I made the mistake of trying to run the C program as a bash script. However, after correcting my mistake, I still get an error...</p>
  
  <pre><code>$ ./hello
  $ bash: ./hello: No such file or directory
  </code></pre>
  
  <p>I have made the binary executable, so that should not be the issue. This error message does not show up when running the same program compiled on the host.</p>
  
  <p><strong>UPDATE</strong>
  Let me clarify a few points.</p>
  
  <ul>
  <li>One executable was built in a ubuntu container and copied onto the ubuntu host. This executable works.</li>
  <li>The other executable was built using an alpine container and copied onto the ubuntu host. This executable does not work.</li>
  <li>Both executables have their executable bit set. When I run ./hello, I do it within the directory where the executable in question resides.</li>
  <li>When I run <strong>file on the executable compiled using the ubuntu container</strong>, I get the following output.</li>
  </ul>
  
  <pre><code>hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=bc9e3e2ecfc026f8077dca28dbbdee4778862d7a, not stripped
  </code></pre>
  
  <ul>
  <li>When I run <strong>ldd on the executable compiled using the ubuntu container</strong> I get the following output.</li>
  </ul>
  
  <pre><code>linux-vdso.so.1 (0x00007ffdbc79e000)
  libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f517b5ae000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f517bba1000)
  </code></pre>
  
  <ul>
  <li>When I run <strong>file on the executable compiled using the alpine container</strong>, I get the following output.</li>
  </ul>
  
  <pre><code>hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, with debug_info, not stripped
  </code></pre>
  
  <ul>
  <li>When I run <strong>ldd on the executable compiled using the alpine container</strong>, I get the following output.</li>
  </ul>
  
  <pre><code>linux-vdso.so.1 (0x00007ffec27f7000)
  libc.musl-x86_64.so.1 =&gt; not found
  </code></pre>