Docker:“未找到”对于现有文件 [英] Docker: "not found" for an existing file

查看:156
本文介绍了Docker:“未找到”对于现有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Docker容器中运行现有的二进制文件。

I'm trying to run an existing binary file in a Docker container.

当前文件夹中的文件:

$ ls .
app  Dockerfile  run.sh

Dockerfile:

Dockerfile:

FROM alpine:latest
COPY . /app/
RUN chmod +x /app/run.sh && chmod +x /app/app
WORKDIR /app
ENTRYPOINT ["./run.sh"]

run.sh:

#!/bin/sh
./app
ls

ls 命令为用于检查 app 是否不存在)

(The ls command is used to check if the app not exists)

Build命令和输出:

Build command and outputs:

$ sudo docker build . -t app_test
Sending build context to Docker daemon  3.427MB
Step 1/5 : FROM alpine:latest
 ---> 11cd0b38bc3c
Step 2/5 : COPY . /app/
 ---> 4c69dfe88b2e
Step 3/5 : RUN chmod +x /app/run.sh && chmod +x /app/app
 ---> Running in 0dbdc9045827
Removing intermediate container 0dbdc9045827
 ---> 9193aeee2c8f
Step 4/5 : WORKDIR /app
 ---> Running in 9ecb2ad7c3f1
Removing intermediate container 9ecb2ad7c3f1
 ---> 1c748d0cb0b2
Step 5/5 : ENTRYPOINT ["./run.sh"]
 ---> Running in 24ebb7500202
Removing intermediate container 24ebb7500202
 ---> adcd6e94a37f
Successfully built adcd6e94a37f
Successfully tagged app_test:latest

运行命令:

$ sudo docker run -it app_test
./run.sh: line 2: ./app: not found
Dockerfile  app         run.sh

来自 ls的输出命令,我们可以找到 app 存在,但似乎 sh 找不到它。

From the output of ls command, we can find app exists, but it seems sh cannot find it.

我也尝试直接运行 ./ app 或使用 [ sh, run.sh ] 而不是 ENTRYPOINT CMD ,但这没有帮助。

I also tried run ./app directly or use ["sh", "run.sh"] instead in ENTRYPOINT or CMD, but it doesn't help.

编辑:此 app 是封闭源代码软件,仅分发已编译的可执行文件。抱歉,我无法提供更多信息。

This app is a closed source software and only a compiled executable is distributed. I'm sorry I cannot provide more information.

推荐答案

如果 app 是一个shell脚本,则错误指向该脚本的第一行,例如如果 / bin / bash 在本地不存在,则#!/ bin / bash

If app is a shell script, then the error refers to the first line of that script, e.g. #!/bin/bash if /bin/bash doesn't exist locally. Can also be windows linefeeds breaking that line.

如果 app 是可执行文件,则错误来自链接库。使用 ldd应用程序查看该二进制文件所针对的内容。对于高山,问题通常是glibc。

If app is an executable, then the error is from linked libraries. Use ldd app to see what that binary is linked against. With alpine, the issue is often glibc.

这篇关于Docker:“未找到”对于现有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆