Every Docker container running in your homelab generates data — database files, uploaded assets, configuration, logs, user content. Lose that data when a container restarts or moves to another host, and you’ve lost everything your service was built on.

Containers are ephemeral by design. Their filesystems vanish on docker rm. Persistent data lives in volumes and bind mounts — but choosing the wrong approach can leave you with slow storage, broken permissions, backup gaps, or containers that can’t migrate between hosts.

This guide covers the four Docker storage options available in every homelab — named volumes, bind mounts, tmpfs, and NFS volumes — with practical patterns for databases, configs, media, and logs. You’ll learn which to use and how to plan a recoverable copy of its contents.


Docker Named Volumes — The Default Choice

Named volumes are Docker-managed storage. Docker creates them, tracks them in its own metadata, and stores them under /var/lib/docker/volumes/ on the host. You reference them by name, and Docker handles the path resolution.

Create and use a named volume in Docker Compose:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# docker-compose.yml
services:
  postgres:
    image: postgres:16
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set a generated password}
      POSTGRES_DB: homelab

volumes:
  pgdata:

Docker creates the volume automatically on docker compose up -d. The volume persists after docker compose down. Remove it explicitly with:

1
docker volume rm homelab_pgdata

When named volumes shine:

  • Databases (PostgreSQL, MySQL, MariaDB, MongoDB) — these need fast, Docker-managed storage without host path dependencies
  • Secrets and app data generated by the container, not edited from the host
  • Multi-node setups — volumes are easier to reference in Swarm or Nomad stacks

When they don’t:

  • You need to inspect or edit files directly from the host (bind mounts are better)
  • You want explicit control over the filesystem path
  • You’re sharing data between multiple containers that need specific directory structures

Named volumes are the default for a reason — they’re portable, Docker-managed, and work across environments without path assumptions.


Bind Mounts — Direct Host Access

Bind mounts map an arbitrary host directory into the container. You control exactly where data lives on the host filesystem.

Bind mount in Docker Compose:

1
2
3
4
5
6
7
8
services:
  nginx:
    image: nginx:alpine
    ports:
      - "80:80"
    volumes:
      - /home/gntech/docker/nginx/html:/usr/share/nginx/html:ro
      - /home/gntech/docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro

The :ro flag mounts read-only for security — the container can’t modify the configuration file.

When bind mounts win:

  • Configuration files — edit nginx.conf or prometheus.yml from the host with your text editor
  • Development — live-reload containers mount your working directory
  • Media libraries — point Plex, Jellyfin, or Navidrome at your existing media folders without moving anything
  • Log directories — collect container logs into a known host path your log collector watches

Bind mount checklist for the homelab:

  • Always use absolute paths to avoid surprises
  • Add :ro for files the container shouldn’t write (config, certs)
  • Check host permissions — the user ID inside the container must have access to the host directory
  • Pre-create directories with correct ownership before starting the container

Named Volumes vs Bind Mounts — When to Use Each

The most common Docker storage question has a straightforward answer:

Aspect Named Volume Bind Mount
Management Docker creates, names, destroys You manage paths manually
Backup Back up /var/lib/docker/volumes/ Back up the host directory
Permission safety Inspect initialization and the selected image UID/GID Host permissions apply directly
Editing files Requires docker exec or root on host Direct file access from host
Performance Native Docker (btrfs, overlay2) Direct host filesystem
Portability Migrate the data and recreate its driver/mount settings Must replicate path structure
Secrets / configs Awkward Ideal

Rule of thumb for the homelab:

Use named volumes for anything the container writes (databases, app state, generated data). Use bind mounts for anything you write (config files, media, development code, log output).

This maps cleanly to real services:

1
2
3
4
5
6
7
8
9
# Named volumes — Docker manages these
docker volume create postgres_data
docker volume create prometheus_data
docker volume create grafana_data

# Bind mounts — you manage these
# /mnt/storage/media → Jellyfin
# /home/gntech/docker/config → container config files
# /var/log/containers → centralized logs

Tmpfs Mounts — In-Memory Storage

Tmpfs mounts store data in RAM. Data disappears when the container stops. Useful for ephemeral, performance-sensitive data that doesn’t need to survive a reboot.

Example — Redis cache with tmpfs:

1
2
3
4
5
services:
  redis:
    image: redis:alpine
    tmpfs:
      - /data:uid=1000,gid=1000,size=100M

Appropriate uses:

  • Redis or Memcached caches (data can be rebuilt)
  • Session stores
  • Temporary processing directories
  • /tmp inside containers (reduces disk writes)

Inappropriate uses:

  • Database data files
  • Uploaded media
  • Configuration state
  • Any data that must survive a restart

Tmpfs is a specialized tool — use it when data loss is acceptable and speed matters.


NFS Volumes — Shared Storage Across Hosts

In a multi-node homelab, volumes on one host aren’t available on another. NFS volumes let containers on any host share the same backing storage.

Set up an NFS share on your Proxmox host or NAS:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# On the NFS server (e.g., Proxmox host at 10.0.20.30)
apt install nfs-kernel-server

# Create and export a volume directory
mkdir -p /srv/nfs/docker-volumes
chmod 755 /srv/nfs/docker-volumes

# Edit /etc/exports
echo "/srv/nfs/docker-volumes 10.0.20.0/24(rw,sync,no_subtree_check,root_squash)" \
  >> /etc/exports

exportfs -a
systemctl restart nfs-kernel-server

Choose ownership for each service directory using its verified UID/GID before starting it. Root squashing does not grant the application write permission automatically. Restrict exports to the intended clients and verify the server-side paths.

Use NFS volumes in Docker Compose:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    volumes:
      - jellyfin-config:/config
      - jellyfin-cache:/cache
      - /mnt/storage/media:/media:ro
    ports:
      - "8096:8096"

volumes:
  jellyfin-config:
    driver: local
    driver_opts:
      type: nfs
      o: addr=10.0.20.30,rw,nfsvers=4,hard
      device: :/srv/nfs/docker-volumes/jellyfin-config
  jellyfin-cache:
    driver: local
    driver_opts:
      type: nfs
      o: addr=10.0.20.30,rw,nfsvers=4,hard
      device: :/srv/nfs/docker-volumes/jellyfin-cache

Or create NFS volumes from the CLI:

1
2
3
4
5
6
docker volume create \
  --driver local \
  --opt type=nfs \
  --opt o=addr=10.0.20.30,rw,nfsvers=4,hard \
  --opt device=:/srv/nfs/docker-volumes/postgres-data \
  postgres_data_nfs

NFS volume considerations:

  • Use mount and locking semantics supported by the application. A soft mount can return I/O errors during an outage and risks data corruption; it is not a general fix for application hangs. hard mounts trade availability for retry behavior, which also needs an outage plan.
  • NFSv3 can support locking through additional services; it is inaccurate to say all older versions have no locking or security. Prefer a version and authentication policy explicitly supported by both endpoints.
  • Preserve root squashing where practical. Align application UID/GID permissions instead of making no_root_squash a default requirement.
  • Test latency and outage behavior. Shared storage does not make a database safe for concurrent writers on multiple hosts.
  • Back up application-consistent data and its configuration, including any dependencies outside the NFS server.

Back up prepared data, then prove recovery

The earlier generic tar loop archived live database volumes and could report success after a failed step. It is removed. A read-only helper mount does not stop other containers writing to a volume, and a configured password variable is useless unless the backup tool actually consumes it.

Use the PostgreSQL atomic dump and recovery lab for database-native dumps, failure propagation, scheduling, and a restore into a new instance. It also tests a separately encrypted Restic copy. For ordinary files, follow the Restic file recovery lab.

For a filesystem archive, first stop all writers cleanly and confirm the application’s supported shutdown/backup procedure. Record volume driver settings, ownership, ACLs, extended attributes, image digests, and credentials. Test recovery into a new empty destination and verify the application before touching the original. A successful tar extraction is not an application recovery test.

Volume cleanup and lifecycle

Inspect first:

1
2
3
docker system df -v
docker volume ls
docker volume ls --filter dangling=true

“Unused” means no container currently references the volume. It does not mean its data is disposable: a removed Compose stack can leave an important named volume behind. Inspect the exact candidate and its container references, then verify an independent recovery copy before deleting it.

Current docker volume prune defaults to unused anonymous volumes; --all includes unused named volumes. Its supported filters are label filters, not until=24h. See the command reference. Labels aid inventory but are not a backup or a dry-run deletion preview.

For routine stack shutdown, retain volumes:

1
docker compose down

The --volumes option removes declared named volumes and attached anonymous volumes within its scope; external volumes and bind-mounted host directories are handled differently. Do not add it to troubleshooting or routine restart commands. Make any data deletion a separate decision after identifying the destination and testing recovery.

This revision received source checks, not a live NFS, volume migration, or application recovery test. The linked labs state their own runtime evidence and boundaries.


Practical Homelab Storage Layout

A battle-tested directory structure for Docker services on a single Proxmox VM or bare-metal host:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
/docker/
├── config/           # Bind-mounted config files per service
│   ├── nginx/
│   ├── traefik/
│   ├── prometheus/
│   ├── grafana/
│   └── frigate/
├── media/            # Large media files (Plex, Jellyfin, Navidrome)
│   ├── movies/
│   ├── tv/
│   ├── music/
│   └── photos/
├── data/             # Bind-mounted data directories (app state)
│   ├── home-assistant/
│   ├── vaultwarden/
│   └── immich/
└── compose/          # docker-compose.yml per service group
    ├── monitoring/
    ├── media-stack/
    └── infrastructure/

Corresponding Docker Compose for a service:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# compose/infrastructure/prometheus.yml
services:
  prometheus:
    image: prom/prometheus:latest
    ports:
      - "9090:9090"
    volumes:
      - /docker/config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus-data:/prometheus
    command:
      - '--storage.tsdb.retention.time=30d'
      - '--storage.tsdb.path=/prometheus'

volumes:
  prometheus-data:    # Named volume for Docker-managed database storage

The pattern: bind mounts for configs and media, named volumes for database-backed writes. This gives you easy config editing from the host plus Docker-managed storage for the data that needs it.


Summary: Choose Your Storage by Data Type

Data type Storage method Example
Databases, app state Named volume PostgreSQL data, Prometheus TSDB
Configuration files Bind mount (ro) nginx.conf, prometheus.yml
Media / user uploads Bind mount Movies, photos, music
Ephemeral cache Tmpfs Redis cache, processing temp dirs
Multi-node shared data NFS volume Jellyfin config, media libraries
Logs Bind mount Container stdout logs for collection

Key takeaways:

  1. Named volumes are the default — use them for anything the container writes. Docker manages permissions, locations, and lifecycle.
  2. Bind mounts for host-edited files — configs, media, log dirs. Keep absolute paths consistent across environments.
  3. Back up early, back up often — one docker compose down -v mistake and your database is gone. Automate volume backups with an application-consistent backup workflow and test its recovery before scheduling.
  4. Use NFS volumes for multi-node setups — but don’t put latency-sensitive databases on NFS. Reserve it for media and config.
  5. Label and review — tag volumes for inventory. Verify ownership, references, and recovery before any separate deletion; an absent label does not make data disposable.

The difference between a well-managed homelab and a brittle one comes down to how you handle data persistence. Containers come and go. Volumes are what survive. Get the storage right, and your services will survive Docker upgrades, host migrations, and the occasional “whoops I deleted the stack” moment.