Start here: https://github.com/ryanwi/rails8-on-docker/generate
NOTE: There are also examples Rails 6 and Rails 7 applications working in Docker
- Rails 8 Applicaiton Docker Template
- Rails 7 Applicaiton Docker Template
- Rails 6 Application Docker Template
- Rails 8
- Ruby 3.3
- Dockerfile and Docker Compose configuration
- GitHub Actions with checks for
- tests
- Linting with Rubocop
- Security scans with Brakeman and bundler-audit
- Building and testing of a production Docker image
- Dependabot for automated updates
Please ensure you are using Docker Compose V2. This project relies on the docker compose
command, not the previous docker-compose
standalone program.
Check your docker compose version with:
% docker compose version
Docker Compose version v2.10.2
docker compose build
docker compose run --rm web bin/rails db:setup
docker compose up
When the app is already running with docker-compose
up, attach to the container:
docker compose exec web bin/rails c
When no container running yet, start up a new one:
docker compose run --rm web bin/rails c
docker compose run --rm web bundle update
docker compose up --build
(adjust tags as needed)
with BuildKit
DOCKER_BUILDKIT=1 docker build --tag rails-on-docker --load .
Test the image can be used and Rails starts up, use a fake key for testing purposes only:
docker run --rm --env SECRET_KEY_BASE=dummy rails-on-docker
docker build --tag rails-on-docker .
Test the image can be used and Rails starts up, use a fake key for testing purposes only:
docker run --rm --env SECRET_KEY_BASE=dummy rails-on-docker
TODO
- Quickstart: Compose and Rails
- Docker Rails Samples
- Docker for Rails Developers Build, Ship, and Run Your Applications Everywhere
- Ruby on Whales: Dockerizing Ruby and Rails development
- Rails generator to produce Dockerfiles and related files
- docker init
- Rails 8 Dockerfile Generator Template
Ryan Williams