Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker无法运行$PATH中未找到的脚本可执行文件;_Docker - Fatal编程技术网

Docker无法运行$PATH中未找到的脚本可执行文件;

Docker无法运行$PATH中未找到的脚本可执行文件;,docker,Docker,我正在使用docker运行一个小的tesseract API。ruby应用程序调用命令行在图像上使用tesseract。在此之前,它首先使用脚本预处理图像: post '/extractText' do begin bas64Image = Base64.decode64(params[:image]) imageFile = Tempfile.new(['image', '.jpg']) imageFile.write(bas64Image) imageFi

我正在使用docker运行一个小的tesseract API。ruby应用程序调用命令行在图像上使用tesseract。在此之前,它首先使用脚本预处理图像:

post '/extractText' do
  begin
    bas64Image = Base64.decode64(params[:image])
    imageFile = Tempfile.new(['image', '.jpg'])
    imageFile.write(bas64Image)
    imageFile.close
    `textcleaner #{imageFile.path} #{imageFile.path}`
    output = `tesseract #{imageFile.path} --psm 6 stdout`
    p output
  rescue
    status 402
    return "Error reading image"
  end
  status 200
  return output.to_json
end
应用程序忽略当前的行
textcleaner{imageFile.path}{imageFile.path}
,因为它不做任何操作

当在命令行中使用类似于
docker的命令运行tess textcleaner receipt3.jpg receipt3.jpg
进行测试时,我得到以下错误:

container_linux.go:265: starting container process caused "exec: \"textcleaner\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"textcleaner\": executable file not found in $PATH".
ERRO[0000] error waiting for container: context canceled

FROM tesseractshadow/tesseract4re

RUN apt-get update && apt-get install -y build-essential ruby-full libffi-dev libgmp3-dev ruby-dev

WORKDIR /home/work

RUN gem install bundler

COPY Gemfile .
COPY textcleaner /home/work
RUN chmod +x /home/work/textcleaner

RUN bundle install

COPY . /home/work

EXPOSE 8080

CMD bundle exec ruby app.rb
我不知道如何将文件添加到$PATH。当我这样做时:

COPY textcleaner $PATH
RUN chmod +x $PATH/textcleaner 
我明白了

chmod: cannot access '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin/textcleaner': Not a directory
The command '/bin/sh -c chmod +x $PATH/textcleaner' returned a non-zero code: 1
在第二行


如果您有任何帮助,我们将不胜感激。

在您的Docker文件中,您应该有以下行:

ENV PATH /path/to/your/textcleaner:$PATH

请在此阅读更多内容

谢谢您的回复,当我将
ENV PATH textcleaner:$PATH
运行chmod+x$PATH/textcleaner添加到我的Docker文件时,我遇到了以下错误:chmod:cannot access
'textcleaner:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin/textcleaner:不是一个目录
您的命令应该是这样的:ENV PATH/home/work/:$PATH,它给了我一个类似错误:
chmod:无法访问“/home/work/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin/textcleaner”:没有这样的文件或目录
您不必复制textcleaner$PATH运行chmod+x$PATH/textcleaner