In the Docker Compose example for WordPress, the Ycode listing [1] says:

   - 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

1 Answer 1


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.

  • so in this case there is no host mapping, and Docker knows that db_data is so to say a link between Wordpress container and the /var/lib/mysql folder in the db container?
    – Ta Mu
    Jun 20, 2017 at 13:18
  • 1
    Host mapping and volumes are two different things. db_data is not an host nor a container, it's a named volume. Remember that the named volumed is declared at the end of the copose file. You are just linking a volume inside a container, that's all. Jun 20, 2017 at 13:53
  • I think, I used an ambigous wording for "host mapping" - I meant "mapping to a host folder"
    – Ta Mu
    Jun 21, 2017 at 6:30
  • I see, actually you have the volumes, that does the "mapping to a host folder" part and you have links, that does the "DNS mapping" part. Jun 21, 2017 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.