简体   繁体   English

Docker 容器中不存在文件

[英]File not exists in Docker container

I have a docker container running and the file structure looks as below.我有一个 docker 容器正在运行,文件结构如下所示。

在此处输入图片说明

My work directory is '/app' and I have copied all files into it from my local system.我的工作目录是“/app”,我已将所有文件从本地系统复制到其中。 Basically, I want to run Apache Bench with SSL support and hence I have copied these 3 files as well into the workdir.基本上,我想在支持 SSL 的情况下运行 Apache Bench,因此我将这 3 个文件也复制到了工作目录中。

  • abs.exe绝对文件
  • libcrypto-1_1-x64.dll libcrypto-1_1-x64.dll
  • libssl-1_1-x64.dll libssl-1_1-x64.dll

My DockerFile looks as below我的 DockerFile 如下所示

FROM python:3.7

COPY requirements.txt /
RUN pip install -r /requirements.txt

COPY ./ /app

WORKDIR /app

CMD [ "python", "ab_script.py"]

and in the file ab_script.py, I am invoking the script在文件 ab_script.py 中,我正在调用脚本

subprocess.Popen(['abs', '-n 100', '-c 10', 'https://my-url.com'], 
                           stdout=subprocess.PIPE,
                           universal_newlines=True)

Though it runs completely fine on my local, I getting the below error when I execute it from Docker.虽然它在我的本地运行完全正常,但当我从 Docker 执行它时出现以下错误。

Traceback (most recent call last):
  File "ab_script.py", line 70, in <module>
    cold_start_process = start_cold_start_process()
  File "ab_script.py", line 28, in start_cold_start_process
    universal_newlines=True)
  File "/usr/local/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'abs': 'abs'

Even though I have placed the file abs.exe in the workdir, it says that the file is not found.即使我将文件abs.exe放在工作目录中,它也说找不到该文件。 Could anyone please let me know where I might be going wrong?任何人都可以让我知道我可能会出错的地方吗? Thanks.谢谢。

If the file is called abs.exe then subprocess.Popen(['abs', ...]) is never going to find it.如果文件名为abs.exeabs.exe subprocess.Popen(['abs', ...])永远不会找到它。 Even if you correct the filename, it still won't work because your current directory is generally not searched for binary names.即使您更正了文件名,它仍然不起作用,因为通常不会在您的当前目录中搜索二进制名称。 You would need to provide an explicit path with the correct name, such as:您需要提供具有正确名称的显式路径,例如:

subprocess.Popen(['./abs.exe', '-n 100', '-c 10', 'https://my-url.com'], 
                           stdout=subprocess.PIPE,
                           universal_newlines=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM