-
Notifications
You must be signed in to change notification settings - Fork 45
Running a Rails application with Docker
Abraham edited this page Sep 23, 2016
·
2 revisions
This how-to will guide you on how to run a Rails application using Docker.
- You have docker installed
- You already have the rails application with a
docker-compose.yml
file
The first step is to recognize the names from the docker-compose.yml
file. It should look like:
version: '2'
volumes:
postgres-data:
driver: local
gems:
driver: local
services:
db:
test: &app
mailcatcher:
web:
<<: *app
We often call the main service to lift the rails server as web
. Let's install the gems:
% docker-compose run --rm web bundle install
This can take a while
Once the command finishes its execution, it is now time to create and migrate the database:
% docker-compose run --rm rake db:create db:migrate db:seed
Finally you are ready to start the web server by just running:
% docker-compose up -d
This last command will run every service on the docker-compose.yml
file meaning run the rails application. You will be able to see the running app at http://localhost:3000. It may take a while befire you can see anything.