Originally published on DevToolHub .
Use a Docker volume when the container owns the data, such as a database or a model cache. Use a bind mount when you need to edit the files on your host, such as source code or a config file. The docker volumes vs bind mounts choice also changes startup behavior and speed. It decides how easy it is to lose data, too. So it's worth testing before you pick.
I ran everything below on Docker Engine 29.4.3 with Docker Desktop for Mac. I didn't test a Linux host, so I flag the spots where it may differ.
What Is the Difference Between Docker Volumes vs Bind Mounts?
A volume is storage that Docker creates and manages for you. A bind mount maps a folder that already exists on your host into the container. Docker's volumes documentation calls volumes the preferred way to persist container data.…