> For the complete documentation index, see [llms.txt](https://devops-3.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devops-3.gitbook.io/devops/docs/module-7-docker/docker-volumes.md).

# Docker Volumes

Docker containers enable apps to execute in an isolated environment. All modifications made inside the container are lost by default when it ends.&#x20;

Docker volumes and bind mounts can be useful for storing data in between run&#x73;**.** One way to store data outside of containers is with volumes.&#x20;

All volumes are kept in a specific directory on your host, typically /var/lib/docker/volumes for Linux systems, and are controlled by Docker.

### What is Docker File System?

A Docker container executes the software stack specified in a Docker image.&#x20;

Images are built up of read-only layers that operate on the Union File System. When we start a new container, Docker adds a read-write layer on top of the image layers, allowing the container to function like a conventional Linux file system.&#x20;

So, each file modification within the container generates a functioning copy in the read-write layer.&#x20;

### Types of Volume Mount

<figure><img src="https://921544542-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiRQTWHUNVZ5tIxQJXclF%2Fuploads%2Fy4BQP3IMGTuywWV2J6Xg%2Ftypes-of-mounts-volume.webp?alt=media&amp;token=dc0aad6a-956e-4557-a066-f808452f2fc7" alt=""><figcaption><p>Volume Types</p></figcaption></figure>

1. Volume

Docker manages volumes kept in a section of the host filesystem (/var/lib/docker/volumes on Linux).&#x20;

This portion of the filesystem shouldn’t be altered by non-Docker processes.&#x20;

In Docker, volumes are the most effective way to store data.&#x20;

Using the docker volume create command, we may directly create a volume, or Docker can do it for us when it creates a container or service.

2. Bind Mount

On the host system, bind mounts can be kept anywhere. These might be crucial system folders or files.&#x20;

They are always modifiable by non-Docker processes running on a Docker host or in a Docker container.&#x20;

Comparatively speaking, bind mounts are less useful than volumes

3. Tmpfs Mount

These mounts are never written to the host system’s filesystem; instead, they are kept solely in the memory of the host system.&#x20;

Neither on the Docker host nor in a container is it stored on a disc.&#x20;

Sensitive or non-persistent state data can be stored on the tmpfs mount for the duration of the container.

### Docker Volume Plugins

Docker Engine volume plugins link Engine installations with external storage systems such as Amazon EBS, allowing data volumes to survive beyond the lifespan of a single Docker host.&#x20;
