Using direct-lvm or host directory as data volume?


So I understand that using the default “loopback” model is not recommended in production.
However I’m not clear if the following configuration is safe for production or not.

I’m interested in preserving the application logs after the container is stopped/removed.

So in order to do this my solution would be to have a dedicated mounted disk and use the -v option to link the log directory to the container.

Now, if the application running inside the container only writes the log files to the log directory is this safe to use with the default loopback model?

Thank you.

There are 2 questions actually.
Direct-LVM vs. Loop-LVM: It’s how you mount docker storage, either automatically (Loop) or manually (Direct). Loop choice automatically creates needed logical volumes as loops (usually as percent of available space in volume group). With Direct-LVM you have to create two logical volumes manually first. One for data, second for metadata (0.1% of data approx.). Loops are slower and unstable therefore Direct-LVM is recommended. More information and how to at

Mounting a data volume into a container with -v switch is what you’re looking for. This divides data from the container. Watch out for difference data volumes and data volume containers! More about at