DevOps Published on 2024-01-20 * 6 min read

Docker for Local Dev: Spinning Up Projects in Minutes

Learn how Docker simplifies local development. Discover how to bootstrap PHP, JavaScript, and full-stack projects in minutes with reproducible environments.

For many developers, setting up a local development environment used to mean installing endless dependencies, configuring databases, and spending hours troubleshooting version mismatches. With Docker, those days are gone.

In this article, I'll share how Docker has transformed the way I and my team work. From onboarding new developers in minutes to keeping projects consistent across machines, Docker has become an essential tool in our daily workflow.

Why Local Development Matters

Before diving into Docker, let's understand why local dev environments are so critical:

  • Speed: Developers need to start coding quickly without fighting setup issues.
  • Consistency: CI/CD pipelines use the same Dockerfiles.
  • Isolation: Each project can have its own dependencies without conflicts.

Docker solves all three problems elegantly.

Docker for Local Dev: The Core Benefits

Rapid Onboarding

When a new developer joins, instead of sending a 5-page setup document, we share a single docker-compose.yml. One command later, their environment is up and running.

docker-compose up -d

Within minutes, they have PHP, MySQL, Node.js, Redis, or whatever services we use - all configured exactly like in production.

Reproducible Environments

We've all heard "but it works on my machine." Docker eliminates that. Containers guarantee the same behavior everywhere. Whether I'm running Ubuntu, a colleague is on Windows, or CI/CD is in the cloud, the environment is identical.

Built-In Isolation

Each project gets its own containerized stack. No more conflicts between different PHP versions or mismatched Node.js dependencies. I can switch between projects seamlessly without breaking anything.

Example: Bootstrapping a PHP + JavaScript Project

Here's a simple docker-compose.yml that spins up a PHP/Laravel API with a Node.js frontend:

version: "3.9"

services:
  app:
    build: ./backend
    volumes:
      - ./backend:/var/www/html
    ports:
      - "8000:80"

  node:
    build: ./frontend
    volumes:
      - ./frontend:/usr/src/app
    ports:
      - "3000:3000"
    command: ["npm", "run", "dev"]

  db:
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: app_db
    ports:
      - "3306:3306"

With one command, we have:

  • A PHP backend running on http://localhost:8000.
  • A Node.js frontend on http://localhost:3000.
  • A MySQL database ready to use.

Why My Team Loves It

  • Hot Reloading: We mount volumes so changes update instantly.
  • Debugging: VS Code integrates directly with Docker containers.
  • Consistency: CI/CD pipelines use the same Dockerfiles.

When someone asks, "How long will it take me to set up the project?", my answer is: about 5 minutes.

Best Practices for Local Docker Dev

  • Use Docker volumes for persistent storage.
  • Add a Makefile with shortcuts (make start, make stop).
  • Keep your images lightweight (Alpine versions when possible).
  • Document your docker-compose.yml so newcomers understand services.

Conclusion

Docker has made local development not just easier but enjoyable. Instead of wasting hours debugging setups, we spend our time coding, testing, and building real features.

If you're still relying on manual setups or heavy virtual machines, give Docker a try - you'll never look back.

Share Article