Search⌘ K

Generating a New Rails App Without Ruby Installed

Explore how to generate a new Rails application inside a Docker container without needing Ruby installed locally. Understand using interactive Bash shells, volume mounting for file sharing, and running Rails commands within the container. This lesson helps you confidently create and manage Rails projects containerized for development.

Interactive Bash shell

We need to run multiple commands in succession in a container in order to generate the Rails project. We could craft a really long, ugly docker run that executes instructions one after another. However, that’s going to be hard to comprehend.

Instead, we can start a container running an interactive Bash shell. This will provide us with a terminal session running inside the container. From there, we can run as many commands as we like, much as if we had a local Bash session.

Note: All the options and commands used below will be explained and run in the later section of the lesson.

We will now start an interactive Bash shell inside a container using the latest ruby image.

$ docker run -i -t --rm -v ${PWD}:/usr/src/app ruby bash 

The option --rm creates a throwaway container that will be ...