Running a Ruby Script Without Ruby Installed

We’re about to perform some magic. Using Docker, we’re going to run a Ruby application without needing Ruby installed on our system.

Have a look at this:

 $ ​​docker​​ ​​run​​ ​​ruby:2.6​​ ​​ruby​​ ​​-e​​ ​​"puts :hello"
 Unable to find image 'ruby:2.6' locally
 2.6: Pulling from library/ruby
 cd8eada9c7bb: Pull complete
 c2677faec825: Pull complete
 fcce419a96b1: Pull complete
 045b51e26e75: Pull complete
 3b969ad6f147: Pull complete
 f2db762ad32e: Pull complete
 708e57760f1b: Pull complete
 06478b05a41b: Pull complete
 Digest: sha256:ad724f6982b4a7c2d2a8a4ecb67267a1961a518029244ed943e2d448d6fb7
 994
 Status: Downloaded newer image for ruby:2.6
 hello

Whoa. What just happened there?

If you look ...

Get Docker for Rails Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.