Docker Storage Explained (Docker Storage Mount Types)

Docker Storage Explained (Docker Storage Mount Types). In this post, we will introduce Docker storage and explain about different storage mount types.

Docker is not new to the IT automation world. It is technically a container management software developed in 2013.

But what are Docker containers?

Broadly, containers are the tools to increase the efficiency of your applications. Docker packages, provisions, and runs containers.

But you can’t store data permanently using containers without Docker storage.

So, what is Docker storage?

Many places inside Docker at the engine and container levels work or use storage. To understand it better, let’s dive deep into understanding Docker and its storage.

So let’s start on Docker Storage Explained (Docker Storage Mount Types).

What are Docker and Docker Containers?

Firstly, Docker became popular in the cloud packaging and application industry because it greatly benefits developers. It is professional open source software that performs OS level virtualization, also called containerization.

You can use Docker to deploy, create, and manage virtualized application containers on an operating system. It can automate application deployment in portable and lightweight containers using docker. Truly, Docker accelerates your workflow and provides you the liberty to innovate your application stacks, tools, and deployment environments for projects.

The tool also enables developers to handle the framework as they handle applications. Docker uses storage drivers to manage the contents of the writable container layer and image layers.

On the other hand, Docker containers run instances of Docker images and store the application and its dependencies. Why it stores applications and their dependencies? Because they are necessary for running the application.

In previous times, application development, reliability and availability were getting difficult. So, better tools were necessary, and that’s why containers were born.

A container is a software unit ideal for packaging code and its dependencies to run the application quickly. The container is important to know to start learning about Docker and its storage.

What is Docker Storage?

We shall remember, that containers cannot write data permanently to a storage location. You must configure Docker storage if you like the container to store data permanently.

The data isn’t available when you delete the container using the remove command because the writable layer is also deleted.

If you don’t store the data in the container, you can use it even if you delete it. The data is gone if a container crashes and you can’t restore or restart it.

But, if you can restart or restore the containers, you can save the data. So, it’s always mandatory to mount the data outside the container.

Docker Storage Mount Types

There are use three types of mounts in your Docker storage, i.e., Volume mount, Bind mount, and tmpfs mounts.

There is a significant difference between the mount types. Volumes have a filesystem on the host, and you can control it through the Docker CLI.

On the other hand, bind mounts use available host filesystem. Whereas tmfs, utilizes the host memory.

That’s not it.

Let’s further understand the details of these mount options available for Docker containers.

Docker Volume Mount

These are the common mount option available for Docker containers. You can manage them using the Docker engine. You can create a Docker volume using Docker commands and share it within the Docker containers.

When you create a Docker volume, you can store it in a directory on the Docker host (/var/lib/docker/volumes/) on Linux. You can isolate the volume from the Docker host, so multiple containers can simultaneously use similar volumes and read write.

When the container is inactive, data persist in volumes. The volume technology is ideal for the permanent storage of container data.

Docker volume has a dedicated filesystem on the host, and it doesn’t depend on the filesystem structure on the host.

You can create Docker volume alone or during container initialization using the command docker volume create.

When stopping or deleting a container, you can permanently store Docker volume. You can delete the volumes manually with the docker volume prune command.

The Docker Volume is ideal for sharing data between multiple containers, backup data, or connecting to a remote location.

Docker Bind Mount

Docker bind mount is another permanent storage with limited options than Docker volume. Hence, you cannot manage it using Docker CLI and depend on the host’s filesystem’s availability.

While running a container, you can create a host filesystem. Evidently, Docker bind mounts are a sort of superset of Volumes.

Bind mounts are the host machine file systems mounted on a Docker container. You can manage them using the host machine.

While using a bind mount, you can mount a directory on the host machine into a Docker container.

The performance is good, but containers rely on the host machine’s filesystem, which has a specific directory structure.

tmpfs mount

These mounts are temporary, and once you stop the Docker container, you lose the data present on these mounts.

But, you can store tmpfs mounts in the host system’s memory only. The mounts don’t hold the data permanently as they are never written to the host system’s filesystem.

tmpfs mounts are useful when you involve sensitive data that you don’t want permanently. A significant difference with these mounts is that the containers can’t share tmpfs space without running on Linux OS.

Furthermore, Docker uses two flags when creating tmpfs volume: tmpfs and mount. The mount flag is newer and supports different options during container start up. It writes temporary filesystems to RAM and not to the host or the container’s filesystem layer at

Docker Storage Driver

It is liable to create a container write layer to log all the changes during container runtime. When a container starts with an image, all layers part of the image lock and read only.

Due to this, you can delete the changes and write to the recording layer when the container stops. The driver creates a Union filesystem enabling filesystems to share from all layers.

All in all, it is the default process to store data in a container until you use the storage technologies highlighted above. Vital to notice that an additional driver layer delivers additional performance overhead. Don’t use the default storage option for write intensive containers like database systems.

Which Mount Type to Use in Docker Containers?

Once you know the different types of mounts for Docker containers, you can decide which one to use.

You can use volumes if you want your Docker to manage the mount points and data. Volumes are also ideal to use if the Docker host doesn’t guarantee to have a directory or file structure.

Also, if the host wants to store your container’s data on a cloud provider or remote host rather than locally.

You can use bind mounts to save your data locally on the host. Also, to share data like configuration files and source code from your Docker host to the Docker container.

tmpfs mounts are great for sensitive information and if you don’t want the data on the host machine or container. Also, for storing secret keys, you can use tmpfs.

Thank you for reading Docker Storage Explained (Docker Storage Mount Types). We shall conclude. 

Docker Storage Explained (Docker Storage Mount Types) Conclusion

Summarizing the article, you can use the right type of mount in your Docker containers using the information. All three offer different features and benefits to help you achieve your desired outcome.

Use Docker as a cloud native container ecosystem to manage, build, and orchestrate your containers in the business network.

Explore the wide use case of the tool and streamline your DevOps operations with finesse.

Read more of our blog about Docker over here

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x