title: Unable to run a Docker image with a Rust executable
body: <p>I am trying to create an image with my binary file (written in Rust) but I get different errors. This is my <code>Dockerfile</code>:</p>
  
  <pre><code>FROM scratch
  COPY binary /
  COPY .env /
  COPY cert.pem /etc/ssl/
  ENV RUST_BACKTRACE 1
  CMD /binary
  </code></pre>
  
  <p>Building finishes fine but when I try to run it I get this:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ docker run binary
  docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown.
  ERRO[0000] error waiting for container: context canceled 
  </code></pre>
  
  <p>And this:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ docker run binary /binary
  standard_init_linux.go:195: exec user process caused "no such file or directory"
  </code></pre>
  
  <p>I have no idea what to do. The error message looks very odd to me. According to the <a href="https://docs.docker.com/develop/develop-images/baseimages/#create-a-simple-parent-image-using-scratch" rel="noreferrer">official Docker documentation</a> it must work.</p>
  
  <p>System info: latest Arch Linux and Docker:</p>
  
  <pre class="lang-none prettyprint-override"><code>Docker version 18.02.0-ce, build fc4de447b5
  </code></pre>
  
  <p>I tested with a C++ program and it works fine, with both clang and gcc.</p>
  
  <p>It does not work with <code>scratch</code>, <code>alpine</code>, <code>busybox</code> ,or  <code>bash</code>-based images, but it does work with <code>postgresql</code>, <code>ubuntu</code>, and <code>debian</code> images.  The exact problem is something related to Rust and lightweight docker images - everything works okay otherwise.</p>