How to Create a Docker Volume
Title: How to Create a Docker Volume
Date: 2024-01-10
Time:10:43
Introduction: *Docker volumes are widely used and useful tools for ensuring data persistence while working in containers. They are a better alternative than compiling additional writable layers, which increase Docker image size. Docker volumes are file systems mounted on docker containers to preserve data generated by the running container.
The volumes are stored on the host, independent of the container life cycle. This allows users to back up data and share file systems between containers easily.
Step 1: To create a Docker Volume use the command:
docker volume create [volume_name]
# Example
docker volume create data
Step 2: To verify you have successfully created a Docker volume, prompt Docker to list all available volumes with:
docker volume list
Step 3: Mounting a Data Volume
# To run a container and mount a data volume to it, follow the basic syntax:
docker run --mount source=[volume_name],destination=[path_in_container] [docker_image]
Misc. Commands:
Notes: