Back to all articles
TechnicalFeature

What Is Docker and Why Does Vibestacks Use It?

Docker eliminates 'works on my machine' problems. Here's what it actually does and why we include it in every Vibestacks project.

What Is Docker and Why Does Vibestacks Use It?

If you've looked at the Vibestacks codebase, you've probably noticed the Docker files. Maybe you're wondering why they're there, or what Docker even is.

Let me break it down without the usual DevOps jargon.

What Problem Does Docker Solve?

You've probably experienced this:

  1. You clone a project
  2. Run npm install
  3. Get 47 errors about missing dependencies, wrong Node versions, or some native module that won't compile

Then you spend 3 hours debugging environment issues instead of actually building your product.

Docker fixes this by packaging everything your app needs into a container - a self-contained environment that runs the same way on every machine.

Think of it like shipping furniture. You could ship individual pieces and hope the recipient has the right tools to assemble them. Or you could ship a fully assembled unit in a protective box. Docker is the protective box.

How Docker Actually Works

Without Docker, your app runs directly on your operating system. It depends on:

  • The right Node.js version being installed
  • The right database being configured
  • Environment variables being set correctly
  • Native dependencies matching your OS

With Docker, your app runs inside a container that has all of these pre-configured. The container is built from a Dockerfile - a recipe that specifies exactly what goes inside.

# Example: A simple Node.js Dockerfile
FROM node:20-alpine

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

CMD ["npm", "run", "dev"]

This says: "Start with Node 20, copy my code, install dependencies, and run the dev server." Anyone who runs this gets the exact same environment.

Why Vibestacks Includes Docker

We include Docker configuration for three reasons:

1. Consistent Development Environment

Every developer on your team gets the same setup. No more "it works on my machine" conversations. Junior devs don't spend their first week fighting environment issues.

The included docker-compose.yml spins up:

  • Your Next.js application
  • PostgreSQL database
  • Any other services you need

One command and everything's running:

docker compose up

2. Production Parity

Your local environment matches production. When you deploy to Vercel, Railway, or any cloud provider, your app behaves the same way it did on your laptop.

This eliminates an entire category of bugs - the ones that only appear in production because something was configured differently.

3. Easy Onboarding

New team member? New contractor? They clone the repo, run docker compose up, and they're ready to contribute. No 10-page setup guide. No tribal knowledge about which brew packages to install.

Docker vs Running Locally

You might wonder: why not just run npm run dev directly?

You absolutely can. For simple projects, running locally works fine. But Docker helps when:

ScenarioWithout DockerWith Docker
New developer joinsHours of setup, debugging environmentdocker compose up
Different Node versions needednvm switching, potential conflictsEach project has its own Node
Database setupInstall Postgres, create databases, configureAutomatic with compose
Testing production build"It worked locally" bugsSame container runs everywhere
CI/CD pipelinesComplex setup scriptsUse the same Dockerfile

The Docker Files in Vibestacks

Here's what each file does:

Dockerfile

The recipe for building your application container. We optimize this for Next.js with:

  • Multi-stage builds (smaller final image)
  • Layer caching (faster rebuilds)
  • Security best practices (non-root user)

docker-compose.yml

Orchestrates multiple containers. For development, this typically includes:

services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://...

  db:
    image: postgres:16
    volumes:
      - postgres_data:/var/lib/postgresql/data

One command starts both your app and database together.

.dockerignore

Like .gitignore but for Docker. Prevents unnecessary files (node_modules, .git) from being copied into your container, making builds faster.

When You Don't Need Docker

To be fair, Docker isn't always necessary:

  • Solo projects on one machine - If you're the only developer and deploy to Vercel, you might not need the complexity
  • Simple static sites - If there's no database or backend services, Docker adds overhead without much benefit
  • Learning phase - When you're first learning Next.js, understanding the basics matters more than containerization

We include Docker in Vibestacks because most SaaS products eventually need it - for team collaboration, for CI/CD, or for self-hosting. Having it configured from day one saves the painful migration later.

Common Docker Commands

If you're new to Docker, here are the commands you'll use most:

# Start all services
docker compose up

# Start in background (detached mode)
docker compose up -d

# Stop all services
docker compose down

# Rebuild after changing Dockerfile
docker compose build

# View running containers
docker ps

# View logs
docker compose logs -f

# Access container shell
docker compose exec app sh

The "Works on My Machine" Certificate

There's a running joke in software development about the "Works on My Machine" certification. Developer says code works. QA says it doesn't. Finger-pointing ensues.

Docker eliminates this. If it works in the container locally, it works in the container everywhere. The environment is the same. The dependencies are the same. The configuration is the same.

This is why companies like Spotify, Netflix, and Uber run everything in containers. Not because it's trendy, but because it solves real problems at scale.

Getting Started

If you're using Vibestacks, Docker is already configured. To use it:

  1. Install Docker Desktop (Mac/Windows) or Docker Engine (Linux)
  2. Run docker compose up in your project directory
  3. Visit localhost:3000

That's it. Your database, your app, everything running in isolated containers.


Docker has a learning curve, but it's one of those tools that pays dividends over time. The upfront investment in understanding containers saves countless hours of environment debugging later.

We've done the configuration work in Vibestacks so you can focus on building your product, not wrestling with infrastructure.

Questions about our Docker setup? Ask in our Discord community.