2.1 KiB
2.1 KiB
| tags | source | created | ||
|---|---|---|---|---|
|
video-accessibility-old | 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
- Identify files/directories that need live updates (e.g., transcription files, AD text configs)
- Instead of copying files into the image at build time, use Docker volume mounts in your docker-compose.yml or docker run command:
volumes: - /opt/video-accessibility/data:/app/data - /opt/video-accessibility/config:/app/config - For direct docker run:
docker run -v /opt/video-accessibility/data:/app/data ... - Update files on the host machine in the mounted directory
- Changes appear immediately in the running container without rebuilding the image
Key Configuration
- Dockerfile: Remove
COPYinstructions for files that change frequently; useVOLUMEdeclarations instead - docker-compose.yml: Add
volumessection mapping host paths to container paths - Permissions: Ensure the container user has write permissions to mounted directories
Gotchas
- Code baked into Docker images with
COPYorADDcommands 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