docker-library / ruby

Docker Official Image packaging for Ruby
http://www.ruby-lang.org/
BSD 2-Clause "Simplified" License
590 stars 334 forks source link

Example on https://hub.docker.com/_/ruby says CMD ["./your-daemon-or-script.rb"], but wouldn't it be CMD ["ruby", "./your-daemon-or-script.rb"] #389

Closed alberto56 closed 2 years ago

alberto56 commented 2 years ago

Using the example on https://hub.docker.com/_/ruby:

FROM ruby:3.0

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1

WORKDIR /usr/src/app

COPY Gemfile Gemfile.lock ./
RUN bundle install

COPY . .

CMD ["./your-daemon-or-script.rb"]

I get exec format error.

However if I use:

FROM ruby:3.0

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1

WORKDIR /usr/src/app

COPY Gemfile Gemfile.lock ./
RUN bundle install

COPY . .

CMD ["ruby", "./your-daemon-or-script.rb"]

It works fine. Would there be an error in the documentation, or is there something I'm not getting?

tianon commented 2 years ago

If you add a proper shebang (something like #!/usr/bin/env ruby) and chmod +x your .rb file, then either will work fine.

alberto56 commented 2 years ago

Thanks! Newbie mistake.