Skip to content
/ docker-next Public template

Next.js dev template with Docker & hot reload — no host Node.js, node_modules in a volume

License

Notifications You must be signed in to change notification settings

Oeht/docker-next

Repository files navigation

Docker Run

Next.js Dev Container Template — App-in-Volume Variant (Docker + Hot Reload, no host Node)

This variant keeps the entire Next.js app inside a Docker volume and bind-mounts only src/ and public/ from your host. You edit source files locally; everything else (package.json, config, node_modules) lives inside the container.

Why this setup?

  • 🧼 Clean host: no node_modules or config clutter
  • ⚡ Hot reload: src/ and public/ are mounted directly → instant updates
  • 🔒 Stable environment: the app (and dependencies) are volume-backed

Quickstart

docker compose up --build
# open http://localhost:3000

On first run, the container scaffolds a Next.js app in a temporary directory (non-interactive), copies it into the volume, and seeds your host src/ and public/ if they are empty.

Volumes & mounts (compose)

  • next-app:/app — full app and configs (volume)
  • ./src:/app/src — host source (bind mount)
  • ./public:/app/public — host assets (bind mount)
  • node_modules:/app/node_modules — dependencies (volume)

Common tasks

# Start / rebuild
docker compose up --build

# Shell inside the container
docker compose exec frontend sh

# Production build & run
docker compose exec frontend sh -lc "npm run build && npm run start"

Notes

  • If you previously ended up with a local node_modules/, delete it once (rm -rf node_modules) so the container volume masks it.
  • To change configs like next.config.* or package.json, exec into the container or copy files out/in as needed.

About

Next.js dev template with Docker & hot reload — no host Node.js, node_modules in a volume

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published