我试图使用我用Rust编写的二进制文件创建一个图像,但是我遇到了不同的错误。这是我的Dockerfile
:
FROM scratch
COPY binary /
COPY .env /
COPY cert.pem /etc/ssl/
ENV RUST_BACKTRACE 1
CMD /binary
建筑完成得很好,但当我尝试运行它时,我得到了这个:
$ 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
还有这个:
$ docker run binary /binary
standard_init_linux.go:195: exec user process caused "no such file or directory"
我不知道该怎么办。这个错误信息对我来说看起来非常奇怪。根据官方Docker文档,这应该是行得通的。
系统信息:最新的Arch Linux和Docker:
Docker version 18.02.0-ce, build fc4de447b5
我用C++程序进行了测试,使用clang和gcc都可以正常工作。
但是,它无法在scratch
、alpine
、busybox
或基于bash
的镜像上工作,但使用postgresql
、ubuntu
和debian
镜像可以正常运行。问题与Rust和轻量级Docker镜像有关-否则一切正常。