Docker 45 🐳 Managing Microservices Environments locally with Docker Compose and Live Reloading
A microservices application has several services, and each one has its own codebase, its own dependencies, and its own runtime. Running the whole stack locally is the daily reality of a developer working on one of those services. The naive approach is to run the service under development with a local toolchain and run the rest of the stack with docker compose up. The problem is the mismatch: the local service may use a different runtime version, a different set of environment variables, and a different network configuration than the containerized version. The service works on the developer’s machine and fails in the container, or vice versa. The solution is to run the service under development in a container too, with the source code bind-mounted from the host and a watcher that reloads the service on every change.
The bind mount is the mechanism that makes live reloading possible. The source directory on the host is mounted into the container at the working directory, so the container sees the host’s files. When the developer edits a file, the change is visible in the container immediately, because the container is reading the same file the host is editing. The watcher — nodemon for Node.js, air for Go, watchfiles for Python, or the framework’s own dev server — detects the change and restarts the process. The container does not need to be rebuilt, and the developer does not need to restart the stack. The loop is: edit, the watcher restarts, the browser refreshes.
The named volume for dependencies is the second half of the pattern. The node_modules directory, the vendor directory, or the Python virtual environment is installed inside the container, and it is mounted as a named volume over the source bind mount. The source bind mount makes the container see the host’s source, but the dependencies must be the container’s, not the host’s, because the container’s runtime and the host’s runtime may differ. The named volume masks the host’s dependency directory and holds the container’s. The result is that the source is shared and the dependencies are isolated, and the two do not conflict .
This chapter covers three areas. First, why local microservices development is hard — the environment-mismatch problem and the bind-mount solution. Second, how to set up live reloading — the bind mount, the dependency volume, the watcher configuration, and the file-system polling problem that arises when the host is not Linux. Third, the patterns for a multi-service stack — the shared network, the service isolation, the database and cache services, and the orchestration scripts that start the right set of services. The chapter ends with a complete example session, a quick reference, best practices, common pitfalls, real-world examples, and diagrams showing the bind-mount and dependency-volume model.
Key point: Live reloading in Docker Compose uses a bind mount to share the source code between the host and the container, and a named volume to isolate the container’s dependencies from the host’s. The watcher inside the container detects the changes and restarts the process. The develop.watch key in the Compose file, or a watcher like nodemon, handles the reloading. On non-Linux hosts, the file-system events may not propagate, so polling is often required.
Why local microservices development is hard
The environment-mismatch problem. A developer runs one service on the host and the rest in containers. The host service uses the host’s runtime, the host’s environment variables, and the host’s network. The containerized services use the image’s runtime, the Compose environment variables, and the Compose network. When the host service tries to reach a containerized service, it must use localhost:port instead of the service name, and the port must be published. When the containerized service tries to reach the host service, it must use the special host.docker.internal hostname or the host’s IP address. The mismatch is a constant source of configuration bugs. Running the service under development in a container eliminates the mismatch: every service uses the same network, the same environment variables, and the same runtime configuration.
The rebuild problem. A container is built from an image, and the image contains the source code as it was at build time. When the developer edits a file, the image is stale, and the container is running the old code. The developer must rebuild the image and restart the container to see the change. For a Node.js service, the rebuild is fast, but the restart interrupts the debugging session. For a compiled language like Go or Rust, the rebuild is slow, and the interruption is significant. The bind mount eliminates the rebuild: the container reads the source from the host, so the change is visible immediately. The watcher restarts the process, and the new code is running without an image rebuild.
The dependency-volume problem. The source directory contains the dependency directory, and if the source is bind-mounted, the container sees the host’s dependencies. The host’s dependencies may be built for a different platform, a different runtime version, or a different architecture. On macOS, the host’s node_modules may contain native modules compiled for macOS, which do not work in the Linux container. The fix is to mount a named volume over the dependency directory, so the container’s dependencies are used instead of the host’s. The named volume is populated when the container is built, and the bind mount does not overwrite it.
The file-watching problem. A watcher detects file changes by subscribing to the operating system’s file-system events. On Linux, the events propagate through the bind mount, and the watcher sees the changes. On macOS and Windows, the file-system events do not propagate through the Docker Desktop file-sharing layer, and the watcher does not see the changes. The fix is to enable polling: the watcher checks the files periodically instead of waiting for events. Polling is slower and uses more CPU, but it works on every platform. The CHOKIDAR_USEPOLLING=true environment variable enables polling for nodemon and chokidar-based watchers.
The multi-service problem. A microservices stack has several services, and the developer is working on one of them. The other services must run, but they do not need to be rebuilt or reloaded. The Compose file defines the whole stack, and the developer starts the stack with the service under development mounted and the others built from their images. The docker compose up command starts the whole stack, and the developer’s service reloads on every change while the other services stay stable.
The trade-off. The bind mount and the live reloading add complexity to the Compose file, and the polling watcher adds CPU usage. The alternative — rebuilding the image on every change — is simpler but slower, and it interrupts the debugging session. For a compiled language, the difference is significant. For an interpreted language, the difference is smaller but still noticeable. The trade-off is between the complexity of the live-reloading setup and the speed of the development loop.
a. The bind mount and the dependency volume
The bind mount maps the host’s source directory into the container’s working directory. The named volume masks the host’s dependency directory and holds the container’s dependencies.
services:
api:
build:
context: ./api
dockerfile: Dockerfile.dev
volumes:
- ./api:/app
- /app/node_modules
ports:
- "3000:3000"
environment:
NODE_ENV: development
CHOKIDAR_USEPOLLING: "true"
The ./api:/app bind mount maps the host’s api directory into the container’s /app directory. The /app/node_modules volume is an anonymous volume that masks the host’s node_modules. The container’s node_modules is populated when the image is built, and the bind mount does not overwrite it.
The anonymous volume syntax /app/node_modules is the short form. The long form uses a named volume:
volumes:
- ./api:/app
- api-node-modules:/app/node_modules
volumes:
api-node-modules:
The named volume is preserved across container restarts, so the dependencies do not need to be reinstalled on every start. The anonymous volume is recreated when the container is recreated.
The Dockerfile.dev installs the dependencies and starts the watcher:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npm", "run", "dev"]
The npm ci installs the dependencies in the image, and the npm run dev starts the watcher. The dev script is defined in package.json:
{
"scripts": {
"dev": "nodemon --watch src --ext js,json src/index.js"
}
}
The nodemon watcher monitors the src directory and restarts the process when a .js or .json file changes. The --watch flag specifies the directory, and the --ext flag specifies the extensions.
b. The watcher configuration
The watcher is the process that detects the changes and restarts the application. Each language has its own watcher, and the configuration determines which files are monitored and how the restart is performed.
Node.js. nodemon is the standard watcher. The configuration is in nodemon.json or in the package.json scripts.
{
"watch": ["src"],
"ext": "js,json,ts",
"ignore": ["node_modules", "dist"],
"delay": 500
}
The watch array specifies the directories, the ext specifies the extensions, the ignore array specifies the directories to skip, and the delay specifies the debounce time.
Python. watchfiles and uvicorn --reload are the common choices. The uvicorn dev server has a built-in reloader.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--reload"]
The --reload flag enables the reloader, which watches the source files and restarts the server.
Go. air is the standard watcher. The configuration is in .air.toml.
[build]
cmd = "go build -o ./tmp/main ."
bin = "tmp/main"
include_ext = ["go", "tpl", "tmpl", "html"]
exclude_dir = ["assets", "tmp", "vendor"]
The air tool rebuilds the binary and restarts the process when a file changes.
The polling configuration. On macOS and Windows, the file-system events do not propagate through the Docker Desktop file-sharing layer. The watcher must use polling, which checks the files periodically. The configuration depends on the watcher:
| Watcher | Polling flag |
|---|---|
nodemon | CHOKIDAR_USEPOLLING=true |
uvicorn | --reload-dir with WATCHFILES_FORCE_POLLING=true |
air | poll = true in .air.toml |
webpack-dev-server | WATCHPACK_POLLING=true |
The polling interval can be configured. A shorter interval detects changes faster but uses more CPU. A longer interval uses less CPU but has a delay. The nodemon default is 1000ms, and the CHOKIDAR_INTERVAL environment variable overrides it.
The Compose develop.watch key. The Compose specification has a develop.watch key that configures the file synchronization and the rebuild triggers. It is a newer feature, and it is supported by Docker Compose v2.22 and later.
services:
api:
build:
context: ./api
develop:
watch:
- action: sync
path: ./api/src
target: /app/src
- action: rebuild
path: ./api/package.json
The sync action synchronizes the files from the host to the container, and the rebuild action rebuilds the image when the specified files change. The develop.watch key is the declarative alternative to the bind mount and the watcher.
c. The multi-service stack
A microservices stack has several services. The Compose file defines all of them, and the developer starts the stack with the service under development mounted and the others built from their images.
services:
web:
image: myapp/web:latest
ports:
- "8080:80"
depends_on:
- api
networks:
- frontend
api:
build:
context: ./api
dockerfile: Dockerfile.dev
volumes:
- ./api:/app
- api-node-modules:/app/node_modules
ports:
- "3000:3000"
environment:
NODE_ENV: development
CHOKIDAR_USEPOLLING: "true"
DATABASE_URL: postgres://app:secret@db:5432/appdb
REDIS_URL: redis://cache:6379
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
networks:
- frontend
- backend
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: secret
POSTGRES_DB: appdb
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 5s
retries: 5
start_period: 10s
networks:
- backend
cache:
image: redis:7-alpine
networks:
- backend
volumes:
api-node-modules:
db-data:
networks:
frontend:
backend:
internal: true
The api service is the one under development. Its source is bind-mounted, its dependencies are in a named volume, and its watcher uses polling. The web, db, and cache services are stable; they are built from their images and do not change. The developer starts the stack with docker compose up, edits the api source, and the api container reloads. The other services are unaffected.
The web service is a reverse proxy or a frontend that forwards the requests to the api service. The db and cache services are the data stores. The networks isolate the backend services from the frontend, so the web service cannot reach the db directly.
The developer can start only the services that are needed:
# Start the whole stack
docker compose up
# Start only the api and its dependencies
docker compose up api
# Start the api with the debug profile
docker compose --profile debug up api
The docker compose up api command starts the api service and its dependencies (the db and cache), but not the web service. This is useful when the developer is working on the API and does not need the frontend.
Complete Example Session
# ============================================
# PART 1: THE API DOCKERFILE
# ============================================
# api/Dockerfile.dev
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev"]
# ============================================
# PART 2: THE PACKAGE.JSON
# ============================================
{
"name": "api",
"scripts": {
"dev": "nodemon --watch src --ext js,json src/index.js",
"start": "node src/index.js"
},
"dependencies": {
"express": "^4.18.0",
"pg": "^8.11.0",
"redis": "^4.6.0"
},
"devDependencies": {
"nodemon": "^3.0.0"
}
}
# ============================================
# PART 3: THE COMPOSE FILE
# ============================================
# compose.yaml
services:
api:
build:
context: ./api
dockerfile: Dockerfile.dev
volumes:
- ./api:/app
- api-node-modules:/app/node_modules
ports:
- "3000:3000"
environment:
NODE_ENV: development
CHOKIDAR_USEPOLLING: "true"
DATABASE_URL: postgres://app:secret@db:5432/appdb
REDIS_URL: redis://cache:6379
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
networks:
- backend
develop:
watch:
- action: sync
path: ./api/src
target: /app/src
- action: rebuild
path: ./api/package.json
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: app
POSTGRES_PASSWORD: secret
POSTGRES_DB: appdb
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app"]
interval: 5s
retries: 5
start_period: 10s
networks:
- backend
cache:
image: redis:7-alpine
networks:
- backend
volumes:
api-node-modules:
db-data:
networks:
backend:
# ============================================
# PART 4: STARTING THE STACK
# ============================================
# $ docker compose up -d
# [+] Running 4/4
# ✔ Container api-db-1 Healthy
# ✔ Container api-cache-1 Started
# ✔ Container api-api-1 Started
# The api service starts with the source mounted.
# The db and cache services are stable.
# ============================================
# PART 5: THE LIVE RELOAD
# ============================================
# $ docker compose logs -f api
# api-1 | [nodemon] 3.0.0
# api-1 | [nodemon] watching path(s): src/**/*
# api-1 | [nodemon] watching extensions: js,json
# api-1 | [nodemon] starting `node src/index.js`
# api-1 | Server running on port 3000
# Edit api/src/index.js on the host.
# The watcher detects the change.
# api-1 | [nodemon] restarting due to changes...
# api-1 | [nodemon] starting `node src/index.js`
# api-1 | Server running on port 3000
# ============================================
# PART 6: THE DEVELOP.WATCH KEY
# ============================================
# $ docker compose watch
# [+] Running 1/1
# ✔ Container api-api-1 Synced
# The develop.watch key synchronizes the files.
# The sync action copies the changed files.
# The rebuild action rebuilds the image.
# ============================================
# PART 7: THE WATCHER CONFIGURATION
# ============================================
# api/nodemon.json
{
"watch": ["src"],
"ext": "js,json,ts",
"ignore": ["node_modules", "dist", "*.test.js"],
"delay": 500
}
# ============================================
# PART 8: THE PRODUCTION OVERRIDE
# ============================================
# compose.prod.yaml
services:
api:
build:
context: ./api
dockerfile: Dockerfile
volumes: !reset []
environment:
NODE_ENV: production
CHOKIDAR_USEPOLLING: !reset null
# The production file resets the volumes and the
# development environment variables.
# ============================================
# PART 9: THE DEVELOPMENT WORKFLOW
# ============================================
# 1. Start the stack
docker compose up -d
# 2. Edit the source
# (the watcher restarts the api service)
# 3. View the logs
docker compose logs -f api
# 4. Run a command in the container
docker compose exec api npm test
# 5. Stop the stack
docker compose down
# ============================================
# PART 10: THE COMPLETE FILE STRUCTURE
# ============================================
# project/
# ├── compose.yaml
# ├── compose.prod.yaml
# ├── .env
# └── api/
# ├── Dockerfile
# ├── Dockerfile.dev
# ├── package.json
# ├── nodemon.json
# └── src/
# └── index.js
The ten parts show the API Dockerfile, the package.json, the Compose file, starting the stack, the live reload, the develop.watch key, the watcher configuration, the production override, the development workflow, and the complete file structure.
Quick Reference
The Live-Reload Pattern
| Component | Purpose |
|---|---|
| Bind mount | Share the source between the host and the container |
| Named volume | Isolate the container’s dependencies from the host’s |
| Watcher | Detect the changes and restart the process |
| Polling | Propagate the changes on non-Linux hosts |
develop.watch | Declarative file synchronization |
The Bind Mount and Volume
| Mount | Syntax | Purpose |
|---|---|---|
| Source | ./api:/app | Share the source |
| Anonymous volume | /app/node_modules | Mask the host’s dependencies |
| Named volume | api-node-modules:/app/node_modules | Preserve the container’s dependencies |
Watchers by Language
| Language | Watcher | Polling flag |
|---|---|---|
| Node.js | nodemon | CHOKIDAR_USEPOLLING=true |
| Python | uvicorn --reload | WATCHFILES_FORCE_POLLING=true |
| Go | air | poll = true |
| Any | webpack-dev-server | WATCHPACK_POLLING=true |
The develop.watch Actions
| Action | Behavior |
|---|---|
sync | Copy the changed files |
rebuild | Rebuild the image |
sync+restart | Sync and restart the container |
The Commands
| Command | Purpose |
|---|---|
docker compose up -d | Start the stack |
docker compose watch | Synchronize the files |
docker compose logs -f api | Follow the api logs |
docker compose exec api sh | Open a shell in the container |
docker compose up api | Start only the api and its dependencies |
Best Practices
✅ Do This:
# Bind-mount the source
volumes:
- ./api:/app # ✅
# Mask the dependency directory
volumes:
- api-node-modules:/app/node_modules # ✅
# Enable polling on non-Linux hosts
environment:
CHOKIDAR_USEPOLLING: "true" # ✅
# Use a separate Dockerfile for development
build:
dockerfile: Dockerfile.dev # ✅
# Use the develop.watch key for declarative synchronization
develop:
watch:
- action: sync # ✅
# Reset the volumes in the production override
volumes: !reset [] # ✅
❌ Don’t Do This:
# Don't bind-mount the source without masking the dependencies
volumes:
- ./api:/app # host's node_modules overwrites the container's # ❌
# Don't use the production image for development
build:
dockerfile: Dockerfile # no watcher, no dev dependencies # ❌
# Don't forget the polling flag on macOS
# The watcher does not see the changes # ❌
# Don't rebuild the image on every change
# Use the bind mount instead # ❌
# Don't ship the development configuration to production
# Use a production override # ❌
Common Pitfalls
| Pitfall | Why It Happens | Fix |
|---|---|---|
| Watcher does not detect changes | File-system events do not propagate | Enable polling |
| Host dependencies override the container’s | Bind mount overwrites the directory | Mask with a volume |
| Native module error | Host and container architectures differ | Install in the container |
| Container restarts in a loop | The watcher restarts on its own files | Ignore the output directory |
| Slow reload | Polling interval too long | Reduce the interval |
| Production ships the dev config | No production override | Use a production file |
| Volume not populated | The image was not built | Run docker compose build |
Real-World Examples
1. The Bind Mount
volumes:
- ./api:/app
2. The Dependency Volume
volumes:
- api-node-modules:/app/node_modules
3. The Polling Flag
environment:
CHOKIDAR_USEPOLLING: "true"
4. The Dev Dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npm", "run", "dev"]
5. The nodemon Script
"dev": "nodemon --watch src src/index.js"
6. The develop.watch Key
develop:
watch:
- action: sync
path: ./api/src
target: /app/src
7. The Production Override
volumes: !reset []
8. Start Only the API
docker compose up api
9. Open a Shell
docker compose exec api sh
10. The Complete Stack
api:
build: { context: ./api, dockerfile: Dockerfile.dev }
volumes: [./api:/app, api-node-modules:/app/node_modules]
environment: { CHOKIDAR_USEPOLLING: "true" }
Visual
The Bind-Mount and Dependency-Volume Model
┌──────────────────────────────────────────────────────────────┐
│ BIND MOUNT AND DEPENDENCY VOLUME │
│ │
│ Host Container │
│ ┌──────────────────────┐ ┌──────────────────────┐ │
│ │ ./api/ │ │ /app/ │ │
│ │ ├── src/ │◄────────►│ ├── src/ │ │
│ │ │ └── index.js │ bind │ │ └── index.js │ │
│ │ ├── package.json │ mount │ ├── package.json │ │
│ │ └── node_modules/ │ │ └── node_modules/ │ │
│ │ (host's) │ masked │ (container's) │ │
│ └──────────────────────┘ └──────────────────────┘ │
│ ▲ │
│ │ named volume │
│ │ api-node-modules │
│ │ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ The bind mount shares the source. │ │
│ │ The named volume masks the host's dependencies. │ │
│ │ The container uses its own dependencies. │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
The Live-Reload Loop
┌──────────────────────────────────────────────────────────────┐
│ THE LIVE-RELOAD LOOP │
│ │
│ 1. Developer edits a file on the host │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ vim api/src/index.js │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 2. The bind mount makes the change visible in the container │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ /app/src/index.js is updated │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 3. The watcher detects the change │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ nodemon: [nodemon] restarting due to changes... │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 4. The watcher restarts the process │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ [nodemon] starting `node src/index.js` │ │
│ │ Server running on port 3000 │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ 5. The browser refreshes │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ The new code is running. │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ No image rebuild. No container restart. │
│ │
└──────────────────────────────────────────────────────────────┘
The Multi-Service Stack
┌──────────────────────────────────────────────────────────────┐
│ THE MULTI-SERVICE STACK │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ frontend network │ │
│ │ ┌──────────┐ │ │
│ │ │ web │ (stable, from image) │ │
│ │ │ nginx │ │ │
│ │ └──────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ backend network │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ api │ │ db │ │ cache │ │ │
│ │ │ (dev) │ │ (prod) │ │ (prod) │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ bind │ │ named │ │ │ │ │
│ │ │ mount │ │ volume │ │ │ │ │
│ │ │ watcher │ │ │ │ │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
│ The api is under development (bind mount + watcher). │
│ The db and cache are stable (from images). │
│ The web is stable (from an image). │
│ │
└──────────────────────────────────────────────────────────────┘
The develop.watch Key
┌──────────────────────────────────────────────────────────────┐
│ THE develop.watch KEY │
│ │
│ services: │
│ api: │
│ develop: │
│ watch: │
│ - action: sync │
│ path: ./api/src │
│ target: /app/src │
│ - action: rebuild │
│ path: ./api/package.json │
│ │
│ ┌──────────────────────────────────────────────────────┐ │
│ │ $ docker compose watch │ │
│ │ │ │
│ │ 1. The sync action copies the changed files. │ │
│ │ 2. The rebuild action rebuilds the image when │ │
│ │ package.json changes. │ │
│ │ │ │
│ │ The watch key is the declarative alternative to │ │
│ │ the bind mount and the external watcher. │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
Summary
| Item | Value |
|---|---|
| Bind mount | Shares the source between the host and the container |
| Dependency volume | Isolates the container’s dependencies |
| Watcher | Detects the changes and restarts the process |
| Polling | Required on macOS and Windows |
develop.watch | Declarative file synchronization |
| Dev Dockerfile | Installs the dev dependencies and starts the watcher |
| Production override | Resets the volumes and the dev variables |
docker compose up api | Starts only the api and its dependencies |
Key takeaways:
- The bind mount shares the source code between the host and the container. The container reads the host’s files, so a change on the host is visible in the container immediately. No image rebuild is required.
- The dependency volume isolates the container’s dependencies. The bind mount would otherwise expose the host’s
node_modules, which may be built for a different platform. The named volume masks the host’s directory and holds the container’s dependencies . - The watcher detects the changes and restarts the process. Each language has its own watcher:
nodemonfor Node.js,uvicorn --reloadfor Python,airfor Go. The watcher runs inside the container and restarts the application when a source file changes. - Polling is required on macOS and Windows. The file-system events do not propagate through the Docker Desktop file-sharing layer. The
CHOKIDAR_USEPOLLING=trueenvironment variable enables polling fornodemon, and the equivalent flags exist for other watchers. - The
develop.watchkey is the declarative alternative. Thesyncaction copies the changed files, and therebuildaction rebuilds the image. It is supported by Docker Compose v2.22 and later . - The multi-service stack runs the service under development with the bind mount and the others from their images. The
docker compose upcommand starts the whole stack, and the developer’s service reloads while the others stay stable. Thedocker compose up apicommand starts only the api and its dependencies. - The production override resets the development configuration. The
!reset []tag removes the volumes, and the!reset nulltag removes the polling variable. The production image has no watcher and no bind mount . - The development and production Dockerfiles are separate. The
Dockerfile.devinstalls the dev dependencies and starts the watcher. TheDockerfilebuilds the production image with the compiled or bundled code.
Remember: Local microservices development with Docker Compose uses a bind mount to share the source and a named volume to isolate the dependencies. The watcher inside the container detects the changes and restarts the process, so the development loop is edit, save, and see the change. On macOS and Windows, polling is required because the file-system events do not propagate. The develop.watch key is the declarative alternative, and the production override resets the development configuration. The result is a development environment that matches the containerized environment, with the speed of local editing and the consistency of containers.
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!