Back to blog

Deploying Rails 8 with Docker and Kamal on DigitalOcean: A 2026 Guide

Learn how to deploy Rails 8 applications efficiently using Docker containers and Kamal on DigitalOcean, with practical steps for Canadian businesses.

May 28, 20268 min readElevenClicks Team

Why Rails 8, Docker, and Kamal Work Together in 2026

Rails 8 represents a mature framework optimized for containerized deployments, and when combined with Docker and Kamal, you get a deployment pipeline that's both powerful and accessible. Docker eliminates the "works on my machine" problem, while Kamal—Rails' native deployment tool—handles orchestration without requiring Kubernetes expertise. For North American businesses running lean DevOps teams, this combination reduces deployment friction significantly.

DigitalOcean remains the platform of choice for mid-market applications in Canada and the US, offering predictable pricing, strong regional availability, and straightforward infrastructure management. By 2026, this stack has become the default for Rails shops moving beyond Heroku.

Prerequisites and Initial Setup

Before starting, ensure you have:

  • Rails 8.0+ installed locally with Ruby 3.3 or later
  • Docker Desktop running (version 4.25+)
  • A DigitalOcean account with API token access
  • SSH keys configured for your local machine
  • Kamal CLI installed via gem install kamal
  • A domain name pointing to your DigitalOcean nameservers

Your local environment should mirror production as closely as possible. Use rbenv or asdf to manage Ruby versions consistently across your team.

Setting Up Your Rails 8 Project with Docker

Creating the Dockerfile

Rails 8 ships with an optimized Dockerfile generator. Run rails generate dockerfile to scaffold your Docker configuration. The generated Dockerfile uses multi-stage builds to keep your image lean, typically resulting in final images under 500MB.

For most Rails 8 applications, the default configuration works well. However, verify these additions if you're using background jobs or caching:

  • Ensure redis-server is included if using ActionCable or Sidekiq
  • Add postgresql-client for database connectivity
  • Include curl for health check endpoints

Building and Testing Locally

Before deploying, build your image locally and test it against a Docker Compose setup that mimics production. Create a docker-compose.yml that includes your Rails app, PostgreSQL 16, and Redis 7.2. Run docker compose up and verify your application boots correctly, database migrations run, and assets compile.

This step catches configuration errors before they reach production and saves hours of troubleshooting on remote servers.

Configuring Kamal for DigitalOcean

Initialize Kamal

Within your Rails project root, run kamal init. This generates config/deploy.yml, the manifest that controls your entire deployment pipeline. Update it with your DigitalOcean infrastructure details.

Essential deploy.yml Configuration

Your config/deploy.yml should include:

  • service name: your application identifier (e.g., "myapp-rails8")
  • image: your container registry path (DigitalOcean Container Registry or Docker Hub)
  • registry: DigitalOcean Container Registry credentials
  • servers: IP addresses of your DigitalOcean Droplets, organized by role (web, job)
  • env: production environment variables including DATABASE_URL, REDIS_URL, RAILS_MASTER_KEY
  • volumes: persistent storage mounts for logs and file uploads
  • healthcheck: endpoint path to verify container health (e.g., "/up")

Kamal automatically encrypts sensitive variables in config/deploy.yml.enc, keeping credentials secure in version control.

Setting Up DigitalOcean Infrastructure

Creating Droplets

Provision at least two Droplets: one for your web tier and one for background jobs. Use Ubuntu 24.04 LTS for stability and extended support. A 2GB/2vCPU Droplet ($12/month) handles most Rails applications comfortably during initial deployment.

Configure a DigitalOcean Firewall that allows:

  • Inbound: port 22 (SSH), 80 (HTTP), 443 (HTTPS)
  • Outbound: all traffic (for package updates and external APIs)

Database and Cache Setup

Use DigitalOcean Managed PostgreSQL 16 for your primary database—this eliminates database administration overhead. Managed Redis is ideal for caching and ActionCable, avoiding the need to run Redis on your application Droplet.

Managed services cost slightly more but provide automated backups, replication, and security patches. For Canadian businesses with compliance requirements, this is a worthwhile investment.

Deploying Your First Release

Pre-Deployment Checklist

Before running kamal deploy, verify:

  • All secrets are in config/deploy.yml.enc (never commit unencrypted secrets)
  • Your Dockerfile builds successfully locally
  • SSH keys are installed on all Droplets
  • Database migrations are idempotent and tested
  • Your domain is pointing to your DigitalOcean Load Balancer IP

Initial Deployment

Run kamal deploy. Kamal will:

  1. Build your Docker image using your local Docker daemon
  2. Push the image to your registry
  3. Connect to each Droplet via SSH
  4. Pull the image and start containers
  5. Run database migrations
  6. Configure Traefik reverse proxy automatically
  7. Set up SSL certificates via Let's Encrypt

Your first deployment typically completes within 5-10 minutes. Monitor progress with kamal logs -f to watch container startup in real-time.

Ongoing Operations and Scaling

Kamal makes updates effortless. After pushing code changes to your repository, simply run kamal deploy again. Kamal handles rolling deployments, ensuring zero downtime by replacing containers one at a time.

For background jobs, add a separate Droplet to your config/deploy.yml with role job, and Kamal will run the same container with a different command (bundle exec sidekiq or similar). This separation keeps your web tier responsive under load.

As traffic grows, add more web Droplets and update your DigitalOcean Load Balancer configuration. Kamal supports multiple servers per role, making horizontal scaling straightforward.

Wrapping Up

Deploying Rails 8 with Docker and Kamal on DigitalOcean gives Canadian and North American businesses a reliable, cost-effective alternative to platform-as-a-service solutions. You retain full control over your infrastructure while avoiding Kubernetes complexity. The combination matures each year, and by 2026, it's the default choice for serious Rails applications.

If your team lacks the expertise to configure this stack or manage ongoing deployments, ElevenClicks specializes in Rails infrastructure and DevOps solutions across Canada and North America. We'll design, deploy, and maintain your Kamal-based infrastructure, freeing your team to focus on product development. Contact ElevenClicks today for a consultation.

Free Consultation

Working on something similar?

ElevenClicks helps Canadian businesses build ruby on rails solutions that actually work. Book a free 30-minute call — no pitch, just honest advice.

Ontario-based · Canadian timezone · No offshore handoffs