#StackBounty: #docker #rust #dockerfile Unable to run the docker image with rust executable

Bounty: 50

I am trying to create an image with my binary file (written in Rust) but I get different errors. This is my Dockerfile:

FROM scratch
COPY binary /
COPY .env /
COPY cert.pem /etc/ssl/
ENV RUST_BACKTRACE 1
CMD /binary

Building finishes fine but when I try to run it I get this:

$ 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 

And this:

$ docker run binary /binary
standard_init_linux.go:195: exec user process caused "no such file or directory"

I have no idea what to do. The error message looks very odd to me. According to the official docker documentation it must work so.

System info: latest archlinux, docker:

Docker version 18.02.0-ce, build fc4de447b5

P.S. Tested the same with C++ – works fine, with both clang and gcc.

P.P.S. It does not work with scratch, alpine, busybox,bash-based images. But it works withpostgresql,ubuntu,debian` images. So the problem exactly in something related to rust and lightweight docker images – everything works okay otherwise.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.