I’m confused about something. I’m new to using volumes and trying to understand something about an application that needs persistent file storage, like WordPress. I’m using this image: https://hub.docker.com/_/wordpress. The docker-compose.yml file uses a volume to store the MySQL data:
volumes: - db_data:/var/lib/mysql
Which I think I understand how that part works, but what I don’t understand is where are the changes files stored? For example, if I install a WordPress plugin, yes, the MySQL data storage is persistent, but about the plugin files that are added to the file system? What am I missing here?
If you declare a named volume in a compose file, it will be bound to the docker-compose lifecycle. It will be created on docker-compose up and destroy with docker-compose down. If you want to uncouple the named volume, you need to create the volume outside the compose file (docker volume create …) and use it inside the compose file by declaring the volume as “external: true” .
You can use docker inspect db_data to see where it is stored. Though, since everything is prefixed with “foldername_” it might be docker inspect {foldername_}db_data instead.
Typicaly /var/lib/docker is the docker root dir, which leads to files beeing in /var/lib/docker/volumes/{volumename or a random id}/. You can check your root dir with docker info | grep "Root"