Reputation: 156
I am trying to run my image, but I get the error described in the title, it seems to not be able to locate a file / directory. I have googled around and found various fixes, but nothing worked for me.
In the container logs I found /usr/bin/env: ruby.exe : No such file or directory, so it seems to have some issue there.
My Dockerfile:
FROM ruby:2.3.3
# Set the working directory to /app
RUN apt-get update -qq && apt-get install -y build-essential nodejs
ENV APP_HOME /fitnesspage
RUN mkdir $APP_HOME
ADD . $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
RUN bundle install
RUN chmod 0777 -R $APP_HOME
RUN useradd -m myuser
USER myuser
CMD bin/rails server
My bin/rails:
#!/usr/bin/env ruby.exe
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
I think from what I am reading that it struggles with the CMD in the Dockerfile, but I don't know how to proceed to fix it. I have tried to change #!/usr/bin/env ruby.exe to #!/usr/bin/env ruby in bin/bundle, bin/rails and bin/rake. Made no difference except for the error.
EDIT: The error changed to /usr/bin/env: ruby : No such file or directory instead.
Upvotes: 1
Views: 2775
Reputation: 36773
Try this:
CMD ruby bin/rails server
It seems that /usr/bin/env is not able to find Ruby. But as you use the official ruby base image, the ruby
command is available.
Upvotes: 1