Is there any performance difference between following docker named volumes vs bind mounted volumes? If yes, how much numbers are we talking about?
- Docker volume example:
docker run -v mysql:/var/lib/mysql mysql:tag
- Docker bind mount example:
docker run -v /path/to/mysql-data:/var/lib/mysql mysql:tag
These containers are used for mostly databases like elasticsearch, mysql and mongodb. Which one should I prefer?
asked Nov 1, 2020 at 7:24
Shinebayar GShinebayar G
5,2006 gold badges22 silver badges33 bronze badges
1
On a couple of platforms (MacOS, Windows with WSL 2) bind mounts are known to be especially slow.
Beyond that, you shouldn't see a perceptible performance difference between named volumes, the container filesystem, files in the image (regardless of the number of layers), or bind mounts (particularly on native Linux).
A good general rule might be to use bind mounts for config files and log files, where I/O is relatively rare but you as a human need to access the files directly; named volumes for database storage and other content where I/O is relatively frequent but as a human you can't directly read the files; and the image itself for your application code.
7,4632 gold badges31 silver badges45 bronze badges
answered Nov 1, 2020 at 12:10
David MazeDavid Maze
161k46 gold badges249 silver badges289 bronze badges
4
Explore related questions
See similar questions with these tags.