If you’ve ever pushed code that “worked on your machine” but broke everywhere else, you’re not alone.
That’s the curse of inconsistent environments: one laptop uses Node 18, another uses Node 20, and suddenly your build explodes.
Docker fixes that. It lets you run your entire app, dependencies, tools, databases, and all inside an isolated environment that works the same everywhere.
You can think of it as a mini-computer inside your computer that you can start, stop, and throw away whenever you like.
Back in the day we had to spin up virtual machines, but now everything is containerized.
In this guide, you’ll learn how to:
- Download and install Docker
- Clone your GitHub repo
- Write a simple Docker setup for development
- Run and preview your app locally
- Push changes back to your repo
Whether you’re a beginner or a late-night vibe coder turning a creative idea into a real project, this walkthrough will get your local environment up and running fast.
1. Install Docker
First, go to the official Docker site and download the installer for your operating system: (src: Docker.com).
Windows
On Windows, download Docker Desktop for Windows. It includes Docker Engine, Docker Compose, and WSL 2 (Windows Subsystem for Linux) integration.
Step 1: Download and run the installer from Docker’s website.
Step 2: When prompted, make sure Use WSL 2 instead of Hyper-V is checked. Docker Desktop relies on WSL 2 for performance and compatibility.
Step 3: Complete installation, then reboot your computer.
Step 4: Open Docker Desktop. It should start running in the system tray automatically. You’ll see the little whale icon appear.
Step 5: Verify Docker works by opening PowerShell or your preferred terminal and running:
docker --version
docker compose version
docker run hello-world
If you see a friendly message that says “Hello from Docker!”, you’re good to go. If not, make sure WSL 2 is installed and running by opening a PowerShell window and running:
wsl --install
Then restart Docker Desktop again.
macOS
Install Docker Desktop for Mac (Intel or Apple Silicon). It comes bundled with everything you need. Once installed, open the Docker whale icon from the menu bar to start it.
Verify installation:
docker --version
docker compose version
docker run hello-world
Linux
Most distributions have a Docker package:
sudo apt install docker.io docker-compose-plugin
Start the service and verify it’s running:
sudo systemctl enable --now docker
Then confirm your installation:
docker --version
docker compose version
docker run hello-world
If you see “Hello from Docker!”, you’re ready.
2. Clone Your Repository Locally
Now let’s pull your code down from GitHub (or wherever it lives) so you can run it locally.
git clone https://github.com/yourusername/your-repo.git
cd your-repo
If your project doesn’t have a Git repo yet, create one:
git init
git add -A
git commit -m "Initial commit"
At this point, your code lives safely on your computer. Next, we’ll containerize it.
3. Write a Simple Dockerfile
A Dockerfile is a set of instructions that tells Docker how to build your app environment. Let’s start with a common example using Node.js. You can easily adapt it for Python, PHP, or any other stack.
# Start with a lightweight Node.js image
FROM node:20-alpine
# Set working directory
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm ci
# Copy the rest of your app
COPY . .
# Expose the app port
EXPOSE 3000
# Default command to start your app
CMD ["npm", "start"]
Save that in your project root as Dockerfile.
Create a .dockerignore file
This keeps unnecessary files out of your image and makes builds much faster:
.git
node_modules
.env
.DS_Store
4. Build and Run Your Container
Now that you have a Dockerfile, it’s time to build an image. This is basically a snapshot of your app environment.
docker build -t my-app .
Once it’s built, run it:
docker run -p 3000:3000 my-app
Your app should now be live at http://localhost:3000 🎉
If you make code changes, you’ll need to rebuild the image. Alternatively, you can use Docker Compose to make this easier for development.
5. Use Docker Compose for Local Development
Docker Compose lets you define how multiple services (like web and database) run together. It also mounts your local code into the container so you can edit live.
Create a file called docker-compose.yml in your project root:
version: "3.9"
services:
web:
build: .
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
environment:
- NODE_ENV=development
Now run:
docker compose up --build
You’ll see logs appear as your app starts. Visit localhost:3000 again. Any changes you make to your local files will instantly appear inside the container.
Stop the app anytime with Ctrl + C.
6. Commit and Push Your Changes
When your environment works, commit your new files:
git add Dockerfile docker-compose.yml .dockerignore
git commit -m "Add Docker dev environment"
git push origin main
Now your entire team can spin up the same setup by just cloning the repo and running docker compose up.
7. Optional: Preview and Deploy
You can build a production image and deploy it anywhere Docker runs, such as AWS, Render, Fly.io, or a VPS:
docker build -t yourusername/yourapp:latest .
docker push yourusername/yourapp:latest
Your CI/CD pipeline can then automatically deploy that image on merge. The result is a consistent, repeatable, and portable setup.
For the Vibe Coders
Maybe you started on CodePen, Loveable, or StackBlitz, vibing, experimenting and chasing flow at 2 a.m. That’s valid energy. But sooner or later, you’ll want to own your stack.
Here’s how to turn that creative prototype into a real local dev environment:
- Export your project. Most online editors let you download a ZIP or link a GitHub repo.
- Initialize Git (if needed):
git init
git add -A
git commit -m "vibe project begins"
- Drop in the Docker setup above. It creates a portable environment that behaves the same on every machine.
- Run it locally:
docker compose up --build
- Edit live and push when ready. You’ve just leveled up from “vibe coding” to “version-controlled developer.”
Now every time you hit save, you’re working inside a real environment, not just a browser tab. That’s power.
Final Thoughts
Docker might feel intimidating at first, but once you see it in action it becomes one of the most empowering tools in a developer’s workflow. You can ship faster, debug smarter, and stop fighting the “it works on my machine” monster for good.
Next, try adding a database service like PostgreSQL or MongoDB to your docker-compose.yml, or connect this setup to a GitHub Actions pipeline for automatic testing and deployment.
Tip: Keep your Dockerfile and docker-compose.yml in version control. Future you (and your teammates) , will thank you. 🤓
Written by Katelyn Pauley, developer, designer, and builder of high-impact digital systems. Follow for more practical guides that make modern development actually make sense.