DEV Community

Alex Boguslavets
Alex Boguslavets

Posted on • Originally published at alexxdevops.com

Docker for Beginners: Containerize Your App in 30 Minutes

"It works on my machine" — the most dreaded phrase in software development. Docker eliminates this problem entirely. When your app runs in a Docker container, it runs the same way everywhere: on your laptop, on your colleague's Mac, on a Linux server in AWS.

Key Concepts in Plain Language

Image — a blueprint (recipe) for your container. Think of it as a snapshot of a configured system.

Container — a running instance of an image. You can run multiple containers from the same image.

Dockerfile — a text file with instructions on how to build your image.

Docker Compose — a tool for running multiple containers together (e.g., your app + database + Redis).

A Real Dockerfile Example

Here's a Dockerfile for a Rails application:

FROM ruby:3.3

WORKDIR /app

COPY Gemfile Gemfile.lock ./

RUN bundle install

COPY . .

EXPOSE 3000

CMD ["rails", "server", "-b", "0.0.0.0"]
Enter fullscreen mode Exit fullscreen mode

Six lines that package your entire application into a portable container.

Docker Compose: The Real Power

Most applications need more than one service. Docker Compose lets you define everything in one file:

services:
  web:
    build: .
    ports:
      - "3000:3000"
    depends_on:
      - db
  db:
    image: postgres:16
    volumes:
      - pgdata:/var/lib/postgresql/data
Enter fullscreen mode Exit fullscreen mode

Run docker compose up and your entire stack starts in seconds.

When to Use Docker

  • Your team works on different operating systems
  • You need consistent environments across dev, staging, and production
  • You want to simplify deployment and scaling
  • You're setting up a CI/CD pipeline

If you're still installing dependencies manually on each server, Docker will change your workflow forever.


Need help containerizing your application? Let's talk.

Top comments (0)