Good afternoon! I don’t understand how, in the official mysql image, when you start the container, the data that / var / lib / mysql (volume) are all files are automatically forwarded to the host machine, how does it work?
Would you please share your docker-compose.yml? Your post doesn’t mention important facts and leaves them to the imagination.
This is where you declare a bind-mount, which results that everything inside the containre folder /var/lib/mysql will be stored in the subfolder db, relative to the the folder where you docker-compose.yml is located.
See: https://docs.docker.com/compose/compose-file/compose-file-v2/#volumes for the documentation in the docker compose reference v2; If you are interessted in further details check https://docs.docker.com/storage/bind-mounts/ - even though it does not focus on the docker-compose.yml syntax, they are the very same concepts.
You was mount db Folder to var/lib/mysql
Means Yours In your db Folder use access var/lib/mysql all data.