Repaso
Español
Cloud & DevOpsCoreOPS-05

Why mount a volume for a PostgreSQL container?

Options

  1. To speed up the queries that the database handles in memory
  2. Container data is lost when the container is removed; a volume keeps it (Correct option)
  3. Volumes are needed so that the container can expose its ports
  4. To share the kernel of the host with the database process

Answer

Data in the container's writable layer is lost when the container is removed; a volume persists it

Why

Containers are meant to be disposable: you delete and recreate them on every update. Anything written inside the container is deleted with it.

A volume is storage managed outside the container's lifecycle. Mounting it at the database's data folder keeps the data when the container is replaced.

Remember

Data that must survive → volume.

Key terms

Practice this question in Repaso