The error message
Are you trying to mount a directory onto a file (or vice-versa)? in Docker Compose typically occurs when there is a mismatch between the source and destination paths specified for a volume mount.
- Docker Compose
- Try updating Docker and Docker Compose to the latest version.
- Restart Docker Compose stack.
- Validate there are no typos.
docker system prune.
docker volume prune.
- Make sure that the host (source) path exists.
- This issue could appear if running multiple Compose files and these bind mounts with relative paths are not being part of the first specified Compose file. See here why. Update relative paths or use absolute paths.
In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.