Chapter

Data and volumes

Keep data alive beyond a container's life with volumes and bind mounts.

Docker Basics 3 Lessons from courses

About this chapter

Containers are disposable, and so is the data inside them - unless you tell Docker otherwise. This chapter shows how to persist and share data.

Lessons from courses

  1. 1 Why data disappears Understand why data written inside a Docker container is ephemeral and disappears when the container is removed - and how to keep it safe.
  2. 2 Volumes Learn how to create and use Docker volumes with docker volume and -v to keep data, like a database, safe even when containers are removed.
  3. 3 Bind mounts Learn how Docker bind mounts link a folder on your computer into a container with -v, ideal for editing source code during local development.
Docker Basics Go to course