Description
When containers mount the same host path or volume, each writer changes the files seen by the others.
Potential impact
Concurrent writes can corrupt data. A compromised writer can also change files that another service loads.
Remediation
Give each service its own data path when it can work independently. If services need the same files, coordinate writers and give readers read-only mounts.
Examples
Both services initially mount ./logic at /app. The change points backend at ./bin. Put the files backend needs there before switching.
Before
yaml
version: "3"
services:
frontend:
build: frontend
volumes:
- ./logic:/app
backend:
build: backend
volumes:
- ./logic:/app
After
yaml
version: "3"
services:
frontend:
build: frontend
volumes:
- ./logic:/app
backend:
build: backend
volumes:
- ./bin:/app