Bind Mount connects your local PC folder directly to a container folder. The container reads files from your PC and any changes reflect instantly — no image rebuild needed.

Used mainly during development when you are making frequent code changes and do not want to rebuild the image every time.


The Problem Without Bind Mount

Every code change requires a full rebuild:

# Change 1
docker build -t myapp:v1 .
docker run myapp:v1

# Change 2 — have to rebuild
docker build -t myapp:v2 .
docker run myapp:v2

# Change 3 — rebuild again
docker build -t myapp:v3 .
docker run myapp:v3

Every small change means waiting for a full build. Slow and annoying during development.


Solution — Bind Mount

docker run -it -v C:\\Users\\DakshSaini\\testapp:/app <image-id>

Now:

  1. Edit your file in VS Code on your PC
  2. Save
  3. Run the container again
  4. Changes are there immediately — no rebuild

Syntax

docker run -v <local_folder>:<container_folder> <image_id>

Examples:

# Mount project folder to /app inside container
docker run -it -v C:\\Users\\DakshSaini\\testapp:/app 805c37445902

# Using image name instead of ID
docker run -it -v C:\\Users\\DakshSaini\\testapp:/app daksh12398/testingapp:01

# Run a specific file
docker run -it -v C:\\Users\\DakshSaini\\calculator:/app 805c37445902 python /app/calc.py