In this lesson, we will take a deeper look into using volumes with our Docker containers. Volumes are the preferred method for maintaining persistent data.
Volumes are easier to back up or migrate than bind mounts. You can manage volumes using Docker CLI commands or the Docker API. They work on both Linux and Windows containers. Volumes can be more safely shared among multiple containers. Volume drivers allow for:
Storing volumes on remote hosts or cloud providers
Encrypting the contents of volumes
Add other functionality
New volumes can have their content pre-populated by a container.
Step 1: Create a new volume for an Nginx container:
dockervolumecreatehtml-volume
Step 2: Creating a volume using that volume mount: