---
tags: [tech-patterns, auto-generated]
source: video-accessibility-old
created: 2026-05-01
---

# Docker Volume Mounts for Development: Avoiding Baked Code Issues

## When to use
When deploying applications in Docker containers where code or configuration changes need to be reflected immediately without rebuilding the entire image. Prevents the common mistake of "baking in" code at build time and then wondering why file updates don't appear in the running container.

## Prerequisites
- Docker installed and running on the server
- Application deployed in a Docker container
- Need to iterate on code/configuration without full image rebuilds

## Steps
1. Identify files/directories that need live updates (e.g., transcription files, AD text configs)
2. Instead of copying files into the image at build time, use Docker volume mounts in your docker-compose.yml or docker run command:
   ```yaml
   volumes:
     - /opt/video-accessibility/data:/app/data
     - /opt/video-accessibility/config:/app/config
   ```
3. For direct docker run: `docker run -v /opt/video-accessibility/data:/app/data ...`
4. Update files on the host machine in the mounted directory
5. Changes appear immediately in the running container without rebuilding the image

## Key Configuration
- **Dockerfile**: Remove `COPY` instructions for files that change frequently; use `VOLUME` declarations instead
- **docker-compose.yml**: Add `volumes` section mapping host paths to container paths
- **Permissions**: Ensure the container user has write permissions to mounted directories

## Gotchas
- Code baked into Docker images with `COPY` or `ADD` commands will not reflect host-side changes—the container uses the image snapshot
- If changes don't appear, verify the volume mount path is correct and the container was restarted after mounting changes
- File permissions between host and container can cause issues; use explicit user IDs if needed
- Volume mounts only work for data/config; for code changes during development, either use volume mounts or implement a proper CI/CD pipeline for production

## Source
Project: video-accessibility-old
