Introduction to Volumes and Persistent Data

This lesson is an overview of volumes and persistent data in Docker.

Stateful applications that create and manage data are a big part of modern cloud-native apps. This chapter explains how Docker volumes help stateful applications manage their data.

The TLDR

There are two main types of data — persistent and non-persistent.

Persistent data

Persistent data is the stuff you care about and need to keep. It includes things like customer records, financial data, research results, audit data, and even some types of logs. Non-persistent data is the stuff you don’t care about and don’t need to keep. We call applications that create and manage persistent data stateful apps, and applications that don’t create or manage persistent data stateless apps.

Both are important, and Docker has solutions for both.

Non-persistent data

For stateless apps, Docker creates every container with an area of non-persistent local storage that’s tied to the container lifecycle. This storage is suitable for scratch data and temporary files, but you’ll lose it when you delete the container or the container terminates.

Docker has volumes for stateful apps that create and manage important data. Volumes are separate objects that you mount into containers, and they have their own lifecycles. This means you don’t lose the volumes or the data on them when you delete containers. You can even mount volumes into different containers.

That’s the TLDR. Let’s take a closer look.

Get hands-on with 1300+ tech skills courses.