Bind Mounts

Mount a Host Folder

Example

Serve the local site folder with Nginx. Edit files on your machine and refresh the browser: no rebuild needed. :ro makes the mount read-only inside the container:

docker run -d -p 8080:80 -v "$PWD/site":/usr/share/nginx/html:ro nginx:1.27

Example output

9d8c7b6a5f4e3d2c1b0a...

Live Reload in Development

docker run --rm -it -p 8000:8000 \
  -v "$PWD":/app -w /app \
  python:3.12-slim \
  sh -c "pip install -r requirements.txt && uvicorn app:app --host 0.0.0.0 --reload"
  • Bind mounts are ideal for development; production images should contain the code itself.
  • On Windows, keep projects inside the WSL 2 file system for fast bind mounts.