Persistent storage for containers

Containers are designed to be transient; they run for a while, and then disappear. Anything inside the container disappears with it, including files and data created during the container's run. This isn't always what we want, of course. If you're running a database inside a container, for example, you usually want that data to persist when the container goes away.

There are two ways of persisting data in a container: the first is to mount a directory from the host machine inside the container, known as a host-mounted volume, and the second is to use what's called a Docker volume. We'll look at both of these in the following sections.

Host-mounted volumes

If you want a container to be able to access files on the host ...

Get Puppet 5 Beginner's Guide - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.