Skip to content

Docked Rails CLI

homepage-banner

When developing RoR, it is often necessary to configure the local development environment. However, if you need to configure your development environment in some cloud-based development environments (such as Github Codespaces), it can become quite cumbersome.

But thanks to Docker, we can directly use Docker images to set up our development environment.

Ruby provides Docked (https://github.com/rails/docked) to help us with this environment setup.

Configuration

Assuming you have Docker installed, all you need to do is the following steps to configure Docked Rails Cli:

docker volume create ruby-bundle-cache
alias docked='docker run --rm -it -v ${PWD}:/rails -v ruby-bundle-cache:/bundle -p 3000:3000 ghcr.io/rails/cli'

To make it more convenient for you, you can also put the above commands in .bash_rc or .bash_profile.

Usage

Next, you just need to use docked <command> to execute various commands, such as the following sample provided by the official documentation:

docked rails new weblog
cd weblog
docked rails generate scaffold post title:string body:text
docked rails db:migrate
docked rails server
Leave a message