App Cities
Your app, online
Data

Docker volumes: keep app data outside disposable containers

Understand named volumes, database paths and the difference between restarting a service and protecting data.

App Cities · 2 min · Updated

Docker can replace a container when you deploy a new version. Files kept only inside that container may be lost. A named volume keeps data outside that replaceable part. Use it for things like database files and uploads. A volume is still live storage. It is not a backup.

The steps

  1. Identify every path that contains changing data: database files, user uploads and generated assets. Do not confuse these with source code or dependency caches.
  2. Declare named volumes in Compose and mount them at the paths expected by the service images. Check the image documentation rather than guessing.
  3. Write a test record or upload, restart the service through the supported controls and verify the data is still present.
  4. Enable and test the appropriate backup option for important data. Keep a recovery copy independent of the running application when your needs require it.

A common question

Is a volume automatically a backup?

No. It is active storage. A backup is a separate recoverable copy with a known restore procedure.

Ready to try your project?

Prepare your project, check the prices and choose how you want to deploy.

Keep learning