June 13, 2025
It’s Friday. You’re almost done. You just want to test an idea, run a quick prototype, or help a friend without messing up your local environment.
So… enter one-liners. The kind that saves your day (and your weekend). Spin up a full Ruby app using Docker. No setup. No fuss. Just run and go.
I’ve collected my favorite Ruby and framework-based one-liners in a new repo: https://github.com/ggerman/oneliner
Not Everything Should Be a One-Liner…
If you think solving complex problems with one-liners is a terrible idea —
We totally agree (sometimes ).
Good code is clean.
Good applications are maintainable.
Good developers know when not to be clever.
So if you’re into building things the right way — with proper architecture, testing, and long-term thinking —
Let’s write code that lasts longer than your coffee.
Why?
Because speed matters when you’re:
- Trying out a gem
- Running a script
- Booting a whole Rails app
- Showing off something cool
- Avoiding “it works on my machine” problems
Pure Ruby (Script test)
docker run --rm -it \
-v "$(pwd):/usr/src/app" \
-w /usr/src/app \
ruby:3.2 \
sh -c "gem install test pry && ruby sort.rb"
Sinatra in a Snap
docker run --rm -p 4567:4567 \
-v "$(pwd):/usr/src/app" \
-w /usr/src/app \
ruby:3.2 \
sh -c "gem install sinatra rack puma rackup && ruby app.rb"
Visit http://localhost:4567
Rails in One Shot
Create a new Rails app:
docker run --rm -p 3000:3000 \
-v "$(pwd):/usr/src/app" \
-w /usr/src/app \
ruby:3.2 \
sh -c "apt-get update && apt-get install -y nodejs yarn && gem install rails bundler && rails new rails-app"
Run it:
docker run --rm -p 3000:3000 \
-v "$(pwd):/usr/src/app" \
-w /usr/src/app \
ruby:3.2 \
sh -c "apt-get update && apt-get install -y nodejs yarn && gem install bundler && bundle install && rails s -b 0.0.0.0"
Grape for APIs
docker run --rm -p 9292:9292 \
-v "$(pwd):/usr/src/app" \
-w /usr/src/app \
ruby:3.2 \
sh -c "gem install grape rack rackup puma && rackup -o 0.0.0.0"
One-liner Zen
With great one-liners comes great responsibility:
Be fast. Be lazy. But stay cautious.
- Always know what you’re installing
- Prefer –rm for cleanup
Top comments (0)