Understanding how Docker volumes work with compose In the Docker Compose example for WordPress, the Ycode listing [1] says:

volumes:
   - db_data:/var/lib/mysql


What is exact meaning here? To compare, while using the Docker client, you can map volume to a host folder [2]:

-v /src/webapp:/webapp



  This command mounts the host directory, /src/webapp, into the container at /webapp. 


[1] https://docs.docker.com/compose/wordpress/#define-the-project

[2] https://docs.docker.com/engine/tutorials/dockervolumes/#locate-a-volume
db_data:/var/lib/mysql simply means that the db_data volume that was previously created will be made available in the container at /var/lib/mysql.

In you example it's created at the very end of the compose file.
From the Docker documentation: "The docker volume db_data persists any updates made by Wordpress to the database."

Compose volumes works the same way as the Docker engine.

In you case db_data is just a named volume instead of a path like your second example.