Wrumble
Wrumble

Reputation: 231

Docker cant run script executable file not found in $PATH"

I'm running a small tesseract API using docker. The ruby app calls the command line to use tesseract on an image. Before it does so it uses a script to pre-process the image first:

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

the app ignores the line textcleaner #{imageFile.path} #{imageFile.path} currently as it does nothing.

When testing in command line with something like docker run tess textcleaner receipt3.jpg receipt3.jpg i get the following error:

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

I dont know how to add the file to $PATH. When i do:

COPY textcleaner $PATH
RUN chmod +x $PATH/textcleaner 

I get

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

on the second line.

Any help would be appreciated

Upvotes: 1

Views: 3458

Answers (1)

Iurii Drozdov
Iurii Drozdov

Reputation: 1755

In your Docker file you should have this line:

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

read more here https://docs.docker.com/engine/reference/builder/#env

Upvotes: 2

Related Questions