【问题标题】:Error: IO::Pipe: Cannot exec: No such file or directory错误:IO::Pipe:无法执行:没有这样的文件或目录
【发布时间】:2021-01-05 11:30:15
【问题描述】:

我是 Docker 和 Perl 的新手。 我想 dockerize 我的 perl 应用程序,但在运行时出现以下错误:

Error: IO::Pipe: Cannot exec: No such file or directory

这是我的 Dockerfile:

FROM ubuntu:18.04
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y libimage-magick-perl && \
    apt install -y make && \
    apt install -y gcc && \
    apt install -y perl && \
    apt install -y cpanminus
   
RUN cpan install YAML
RUN cpan install IPC::Run
    
WORKDIR /opt
COPY . /opt/deploy

ENTRYPOINT ["perl", "/opt/deploy/bin/deploy"]

这是我使用 IO::Pipe 模块的文件:

package Deployment::Log::File;

use strict;
use warnings;

use base 'Tie::Handle';

use constant TRUE  => (1 == 1);
use constant FALSE => (0 == 1);

use Fcntl qw(:flock);
use IO::File;
use IO::Pipe;
use Symbol;
use Sys::Hostname;
use Text::ParseWords;
use Time::HiRes;

...
my $class       = shift;  $class = ref($class) if ref($class);
my $destination = shift;
my $layout      = shift;

my $handle;

if ($destination =~ s/^\s*\|\s*//) {
  my @token = map { $class->interpolate($_) } Text::ParseWords::shellwords($destination);

$handle = IO::Pipe->new;
$handle->writer(@token)
  or return undef;

我尝试使用 cpan 和 cpanm 安装 IO::Pipe 和 IO,但没有任何效果。有人可以帮帮我吗?

【问题讨论】:

  • 可能需要查看一些代码。
  • 我假设您检查了 /opt/deploy/bin/deploy、/opt 和 /opt/deploy 存在并且具有正确的权限?
  • @TLP 你能快速告诉如何在 docker 环境中进行操作吗?
  • @TLP 我检查了它,但 /opt/deploy/bin/deploy 在没有目录这是我运行的脚本
  • 您没有显示令牌数组的设置。错误很可能是token指定的命令行无法执行,因为该命令不存在

标签: docker perl ubuntu io cpan


【解决方案1】:

$token[0] 应包含要运行的程序的名称。它可以是路径或简单的文件名(内核使用PATH env var 解析为路径)。

您提供了一个简单的文件名,但在PATH env var 指定的任何目录中都找不到具有该名称的可执行文件,或者您提供了一个不存在文件的路径。

也许程序对其当前工作目录做出了错误的假设?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-28
    相关资源
    最近更新 更多