Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk7 min

Docker Compose Volumes Explained: How to Persist, Back Up, and Restore Data on a VPS

A practical guide to Docker Compose volumes on a VPS: choose named volumes or bind mounts, understand down and down -v, configure external storage, and test backup restores.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a Docker-managed named volume for application data that must survive container replacement on a VPS. Declare the volume in the top-level volumes section, mount it at the application’s real data directory, and run docker compose up. Compose creates the volume once and reuses it on later deployments. A normal docker compose down removes containers but leaves the named volume; docker compose down -v removes the volume and its data.

Volumes are persistence, not a backup. The data still resides on the VPS, so maintain separate archives and test restoring them before treating the setup as recoverable.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How Docker Compose persistence works

Docker defines a volume as a persistent data store created and managed by Docker. The volume lives on the Docker host, which in this case is your VPS, rather than in a container’s writable layer. A container can be destroyed and recreated while the volume remains available to the next container that mounts it.

Compose describes that relationship in YAML. The service declares where the data appears inside the container, and the top-level volumes block declares the storage object:

#1 Best Overall
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
services:
  app:
    image: example/app
    volumes:
      - app-data:/var/lib/app

volumes:
  app-data:

When you run docker compose up, Compose creates app-data if it does not already exist. If the volume exists, Compose reuses it. The application sees its files at /var/lib/app, while Docker stores those files outside the container lifecycle.

The mount path must match the application’s actual data directory. Mounting a volume at the wrong path can leave the real data in the container layer, making it appear to vanish after a replacement. Check the image documentation or vendor instructions before writing the Compose file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What each Compose lifecycle command does to data

Command Container result Volume result
docker compose up Creates or recreates services as needed Creates a declared volume when absent; reuses it when present
docker compose stop Stops the existing containers without removing them Data remains available
docker compose down Stops and removes the Compose containers and network Named volumes remain
docker compose down -v Stops and removes the Compose containers and network Removes Compose-managed named volumes and permanently deletes their stored data
docker volume prune Does not target a particular Compose application Can delete unused volumes, so treat it as a destructive maintenance command

A quickstart demonstration shows why a volume matters: data written only to a container’s writable layer disappears after docker compose down. Mounting the application’s data directory to a named volume keeps the data through a down/up cycle. Do not use down -v as a routine redeploy command unless deleting the data is intentional.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Choose the storage type for your VPS

Decision point Named volume Bind mount
Who manages storage Docker creates and manages the volume object The VPS operator manages a host directory
Compose source A volume key such as app-data A host path such as /srv/app-data
Host-path visibility Files are accessed through Docker’s volume interface Files are directly visible at the chosen host path
Portability Less dependent on a particular host directory layout Depends on the directory existing with the expected path on each host
Backup and migration Docker’s temporary-container archive workflow is straightforward Host backup tools can read the directory directly
Sharing between services Multiple services can mount the same named volume Multiple services can mount the same host directory
Deletion risk Protected from ordinary container removal, but vulnerable to down -v or volume-prune maintenance Subject to any host operation that deletes or changes files in the mapped directory

Use a named volume when Docker should own the data

Named volumes are the default choice for data generated and consumed by containers. They avoid tying the Compose file to a specific VPS directory and are convenient when an application and a backup helper need to share the same data. They also make migration possible without exposing an application to arbitrary host paths.

Use a bind mount when operators need a known host path

A bind mount is appropriate when an operating procedure requires direct host access, such as inspecting files under /srv/app-data with host tools. The trade-off is that every VPS or replacement host must provide the expected directory structure. A Compose file that works on one host can fail to mount correctly if that path is absent or different on another host.

Use a named bind pattern when you need both properties

Compose can expose a stable volume name while mapping it to an existing absolute path through the local driver:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
services:
  app:
    image: example/app
    volumes:
      - app-data:/var/lib/app

volumes:
  app-data:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /srv/app-data

The service uses the stable name app-data, while the actual files reside at /srv/app-data. You still own the host-path dependency, so create and verify that directory as part of VPS provisioning.

Build a volume declaration safely

  1. Identify the application’s real data directory. Use the image or vendor documentation. Configuration files, logs, caches and user data may live in different locations; mount the directory that contains the state you need to preserve.
  2. Declare one top-level volume per persistent data set. Keep the declaration outside services, then attach it under the service that writes the data.
  3. Deploy with docker compose up. The first run creates the volume; subsequent runs reuse it.
  4. Verify the mount before putting the service into production. Create a test record, recreate the service, and confirm that the record is still present.

Keep Compose files, environment files and other configuration backups separate from application-data backups. Rebuilding the containers requires both: the configuration tells Compose what to start, while the volume archive supplies the state.

External volumes and exact platform names

Set external: true when another provisioning or operations system owns the volume lifecycle. Compose will not create an external volume. If the named volume is missing, docker compose up fails instead of silently creating a replacement.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
services:
  app:
    image: example/app
    volumes:
      - shared-data:/var/lib/app

volumes:
  shared-data:
    external: true

Use the name attribute when the Compose key should map to an exact platform volume name rather than a project-scoped name:

volumes:
  app-data:
    name: production-app-data

This is useful when several Compose projects must reference one pre-provisioned volume or when an operations system already dictates the platform name. Document who creates, backs up and retires that external resource; otherwise its ownership will be ambiguous.

Back up a named volume with a temporary container

Docker’s documented archive pattern mounts the data volume and a host backup directory into a short-lived helper container. Stop or quiesce the application first when its files require a consistent snapshot. For a database, use the database’s own dump or backup procedure where required; mounting a live database directory and archiving it does not by itself guarantee a transaction-consistent backup.

Best Value
Sale
UnionSine 500GB Ultra Slim Portable External Hard Drive HDD-USB 3.0 | for PC, Mac, Laptop, PS4, Xbox one, Xbox 360-(Black)
  • [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
  • 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
  • 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
  • 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
  • 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.
  1. Stop writers or put the application in its supported maintenance mode. This prevents files from changing while they are being archived.
  2. Create a backup directory on the VPS. In the example below, $PWD/backups is the host directory that receives the archive.
  3. Archive the volume contents.
    docker run --rm 
      -v app-data:/data:ro 
      -v $PWD/backups:/backup 
      alpine tar czf /backup/app-data.tgz -C /data .
  4. Record which Compose project, volume name and application version produced the archive. Store the archive somewhere that is independent of the VPS when protection from VPS loss matters.
  5. Restart the application and confirm normal operation.

The :ro mount protects the source volume from writes by the archive helper. The resulting app-data.tgz contains the files below the volume root, preserving their relative paths.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Restore and test an archive

Test every backup on a disposable volume before relying on it. A successful archive command proves only that files were read and written; it does not prove that the application can start with them.

  1. Create a disposable target volume.
    docker volume create app-data-restore-test
  2. Extract the archive into that volume.
    docker run --rm 
      -v app-data-restore-test:/data 
      -v $PWD/backups:/backup 
      alpine sh -c 'tar xzf /backup/app-data.tgz -C /data'
  3. Mount the test volume in a temporary Compose project or service. Check that expected files are present and that the application can read them.
  4. For a production restore, stop the application first and preserve the current volume. Make a separate archive of the current state before overwriting anything.
  5. Extract into the production volume only after the test succeeds. Start the service and perform an application-level health check.

If the archive came from a database, follow the database’s supported restore sequence instead of treating a file extraction as sufficient. Restore testing should include permissions, schema or format compatibility, and the application’s ability to open the recovered data.

Quick Recap

Bestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$219.99
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$189.99

Troubleshoot data that appears to be missing

  • The data disappears after a redeploy: confirm that the service mounts the volume at the application’s real data directory. Data written elsewhere remains in the container layer and is lost when that container is replaced.
  • The data disappeared after cleanup: check whether someone ran docker compose down -v or docker volume prune. Both can remove stored data; the former explicitly removes the Compose volumes.
  • A new empty volume appears: verify the volume key, Compose project and exact name setting. A changed name can point the service at a different storage object.
  • An external volume fails at startup: create or provision the required volume outside Compose, then rerun docker compose up. With external: true, Compose intentionally refuses to create a missing resource.
  • A bind mount is empty or points to the wrong files: inspect the absolute host path in the Compose file and ensure the replacement VPS has the same directory layout. Bind mounts depend on that host structure.
  • A restore starts but data is inconsistent: repeat the backup using the application’s quiesce or database-dump procedure. A mechanically valid tar archive is not a guarantee of application consistency.

VPS operating checklist

  1. Identify and document each application’s actual data directory.
  2. Use a top-level named volume unless direct host-path access is a deliberate requirement.
  3. Run a create/recreate test before production deployment.
  4. Keep Compose and environment/configuration backups separate from volume archives.
  5. Back up with the application quiesced or with its supported database backup method.
  6. Restore an archive into a disposable volume and start a test service before trusting it.
  7. Treat docker compose down -v and docker volume prune as destructive commands requiring explicit approval.
  8. Use external: true only when another system clearly owns provisioning and lifecycle management.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.