Data Storage in Docker

Last Updated : 6 Oct, 2026

Docker containers store data in their writable layer, which is removed when the container is deleted. Docker provides persistent storage options to keep data available even after the container's lifecycle ends.

  • Docker Volumes: Docker-managed storage used to persist container data independently of the container.
  • Bind Mounts: Maps a specific file or directory from the host filesystem to a location inside the container.
  • Other Options: Docker also supports tmpfs mounts on Linux and named pipes on Windows.
frame_3775

1. Docker Volume

Docker volumes are Docker-managed storage locations mounted into containers to persist data. They are the preferred storage method because they provide good performance and keep container data isolated from other host processes.

We can use the following command to create docker volume

docker volume create 

We can mount a volume to multiple containers simultaneously and Docker doesn't remove them even if they're not being used by any running container. To remove a volume, we can use the following command -:

docker volume prune

In a Linux filesystem, we can find the available volumes at the following path '/var/lib/docker/volumes/ ', while in Windows, we can get the location of the volume by running the following command in file explorer -:

\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes

To learn more about volumes and how to mount them to a container click here.

Commands to create volume

2. Bind Mounts

Bind mounts allow Docker containers to share files or directories directly with the host filesystem. They are useful when containers need to access or modify specific host files.

  • Host Access: Mounted files can be accessed by both containers and non-Docker processes.
  • Host Path: Requires a specific absolute path on the host filesystem.
  • Limited Management: Cannot be managed as easily through Docker CLI as Docker volumes.
  • Security Risk: Containers can modify or delete files on the host, potentially affecting other processes.

3. tmpfs mounts

tmpfs mounts provide temporary storage for containers by keeping data in the host machine's memory instead of on disk. They are mainly used on Linux when data does not need to persist.

  • Temporary Storage: Data exists only while the container is running.
  • Memory-Based: Stores data in the host's RAM rather than the filesystem.
  • Linux Only: Primarily available when using Docker on Linux.
  • No Sharing: Data cannot be shared between multiple containers.

4.  Named pipes

Named pipes are a special type of mount used mainly with Docker on Windows to enable communication between containers and host processes.

  • Communication: Enables data exchange between containers and host processes.
  • Windows: Primarily used with Docker on Windows.
  • Not Persistent Storage: Unlike volumes, named pipes are designed for communication, not storing container data.
FeatureDocker VolumeBind Mounttmpfs MountNamed Pipe
DefinitionDocker-managed storage for persistent dataMaps a host file/directory to a containerTemporary storage in host memory (RAM)Communication mechanism between host and container processes
Storage LocationDocker-managed area on hostSpecific host filesystem pathHost memory (RAM)Host pipe
Data PersistencePersists after container removalPersists on hostRemoved when container stopsNot intended for data persistence
Managed by DockerYesLimitedYesYes
Host File AccessLimited/direct access not intendedDirectly accessibleNoUsed for communication
SharingCan be shared between containersCan be sharedCannot be shared between containersUsed for process communication
PlatformLinux & WindowsLinux & WindowsMainly LinuxMainly Windows
Best UseDatabases and persistent application dataDevelopment and sharing host filesTemporary or sensitive dataHost-container communication
Comment

Explore