1) in dockerfile use apline 3.8 as base image
2) I had this line in dockerfile,RUN bundle exec rake hello:world --trace
In alpine 3.7 it just works fine, where ruby version is 2.4.5-r0. Rails version is 5.1.2 and puma is 3.12.0
RUN bundle exec rake hello:world --trace
---> Running in 357d4f930bab
** Invoke hello:world (first_time)
** Invoke environment (first_time)
** Execute environment
No executable found at /usr/local/bin/wkhtmltopdf. Will fall back to /app/vendor/bundle/ruby/2.4.0/bin/wkhtmltopdf
** Execute hello:world
hello world
rake aborted!
LoadError: cannot load such file -- etc
/app/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma.rb:5:in `require'
/app/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma.rb:5:in `<top (required)>'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `require'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `each'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:76:in `block in require'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `each'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/runtime.rb:65:in `require'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler.rb:114:in `require'
/app/config/application.rb:19:in `<top (required)>'
/app/Rakefile:4:in `require_relative'
/app/Rakefile:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/rake_module.rb:29:in `load_rakefile'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:703:in `raw_load_rakefile'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:104:in `block in load_rakefile'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:103:in `load_rakefile'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:82:in `block in run'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/lib/rake/application.rb:80:in `run'
/app/vendor/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
/app/vendor/bundle/ruby/2.5.0/bin/rake:23:in `load'
/app/vendor/bundle/ruby/2.5.0/bin/rake:23:in `<top (required)>'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/lib/ruby/gems/2.5.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
/usr/bin/bundle:23:in `load'
/usr/bin/bundle:23:in `<main>'
The command '/bin/sh -c bundle exec rake hello:world --trace' returned a non-zero code: 1
Ruby version: 2.5.2-r0
Rails version: 5.1.2
Puma version: 3.12.0
Alpine: 3.8
Your ruby install is broken, the etc standard library module is missing.
For those coming here with a similar problem, just make sure to apk add ruby-etc in your Dockerfile.
You can also use apk install ruby-full to install ruby with all standard libraries to reduce these kinds of annoying errors.
Probably you both wanted to say apk add, not apk install.
Most helpful comment
For those coming here with a similar problem, just make sure to
apk add ruby-etcin your Dockerfile.