Skip to main content

12 posts tagged with "Docker"

View all tags

colima delete Won't Remove Docker Volumes: Only --data Does

ยท 9 min read

While preparing a colima delete to reset a local Docker environment, two official statements collided: the --help text says "This deletes everything", while the official FAQ says container data "should be reinstated on colima start". Same command, two official stories โ€” at least one is wrong.

This verification happened while maintaining a local Docker dev environment (colima 0.10.3 + docker compose on macOS) that runs a shared PostgreSQL development database.

TL;DRโ€‹

  • Since colima v0.9.0, container data (images, containers, named volumes) lives on a dedicated data disk. A plain colima delete leaves it alone, and the data comes back on the next colima start.
  • colima delete --data is the irreversible one โ€” it deletes the data disk too.
  • The --help text still says "This deletes everything", and plenty of older tutorials describe the old behavior. Trust the behavior: back up your volumes before running any delete.
  • Where volumes actually live: ~/.colima/_lima/_disks/colima/datadisk (a 100 GiB sparse file, 1.2 GiB actual usage measured).

The symptom: two official stories that contradict each otherโ€‹

colima delete's two official accounts contradict each other: --help says everything is deleted, the official FAQ says the data comes back โ€” at least one is wrong.

colima delete --help sounds alarming:

$ colima delete --help
Delete and teardown Colima and all settings.

Use with caution. This deletes everything and a startup afterwards is like the
initial startup of Colima.

Flags:
-d, --data delete container runtime data

The official FAQ entry "How can I delete container data" tells a different story: since v0.9.0, container runtime data uses a different disk, and that disk exists to "guard against accidental data loss after deletion" โ€” the data is reinstated on colima start, and a full wipe requires colima delete --data.

If you carry the "colima delete = volumes gone" expectation, you end up stuck in one of two situations: wanting to reset the VM (upgrade, troubleshooting) but afraid to run delete; or casually adding --data for a "cleaner" reset and later discovering how much that flag actually destroys. Search queries phrase the same question in a dozen ways โ€” "Docker volumes lost", "volumes disappeared after colima delete", "can I recover volumes after colima delete" โ€” and the answer depends on version and flag, not a yes/no.

Root cause: container data moved to a dedicated data disk in v0.9.0โ€‹

A colima VM has two disks, and colima delete treats them completely differently.

colima's two-disk layout: how delete and delete --data differ

Both disks are visible on the host as plain files:

# System disk: a 20 GiB raw GPT disk image holding the VM OS
$ ls -lh ~/.colima/_lima/colima/disk
-rw-r--r--@ 1 cc staff 20G Oct 19 20:57 /Users/cc/.colima/_lima/colima/disk
$ du -sh ~/.colima/_lima/colima/disk
1.4G /Users/cc/.colima/_lima/colima/disk

# Data disk: a 100 GiB sparse file that grows with container data
$ ls -lh ~/.colima/_lima/_disks/colima/datadisk
-rw-r--r--@ 1 cc staff 100G Oct 19 20:57 /Users/cc/.colima/_lima/_disks/colima/datadisk
$ du -sh ~/.colima/_lima/_disks/colima/datadisk
1.2G /Users/cc/.colima/_lima/_disks/colima/datadisk

Inside the VM, Docker's data root sits entirely on the data disk:

$ docker info --format '{{.DockerRootDir}}'
/var/lib/docker
$ colima ssh -- df -h /var/lib/docker
Filesystem Size Used Avail Use% Mounted on
/dev/vdb1 98G 1.1G 92G 2% /var/lib/docker
$ docker volume ls
DRIVER VOLUME NAME
local dev-infra_dev-pg-data

That dev-infra_dev-pg-data is the named volume of the shared PostgreSQL dev database (mounted to /var/lib/postgresql/data in compose) โ€” every byte of it lives on /dev/vdb1, which is backed by the host's datadisk file.

At the source level (colima 0.10.3, Delete in app/app.go), the scope of --data is explicit:

// delete runtime disk if disk in use and data deletion is requested
if diskInUse && data {
log.Println("deleting container data")
if err := limautil.DeleteDisk(); err != nil {
return fmt.Errorf("error deleting container data: %w", err)
}
// ...
}

data is the --data flag. Without it, this branch never runs โ€” what gets deleted is the VM system disk and the configuration, while the data disk file stays on the host. That is also why the FAQ wording changed: colima's own upgrade/troubleshooting docs have long recommended colima delete + colima start to rebuild the environment, and before v0.9.0 that path destroyed your data along with it. v0.9.0 split "delete the environment" from "delete the data", and the FAQ says the new layout exists to "guard against accidental data loss after deletion".

colima delete vs colima delete --data: two delete semanticsโ€‹

Without --data, only the system disk goes โ€” the data disk stays put. With --data, both go.

CommandSystem disk _lima/colima/diskData disk _disks/colima/datadiskNamed volumes
colima deletedeletedkeptback on next colima start*
colima delete --datadeleteddeletedunrecoverable

One more detail hides in the confirmation prompt: the source only adds the second confirmation โ€” "this will delete ALL container data" โ€” when the data disk is absent or --data was passed. A plain colima delete never shows that warning, because by design it never touches your data.

* Honest caveat: "data comes back after a plain delete" comes from the official FAQ plus the source-code branch above; no full deleteโ†’start round-trip was run on the 0.10.3 machine tested here โ€” not worth gambling a working dev environment on. If you want to test it yourself, back up first using the next section.

Three situations still lose data:

  1. colima 0.8.x and earlier: no dedicated data disk โ€” everything sits on the system disk, so a plain delete really does delete everything. The old advice was true in that version range.
  2. Passing --data, or manually running limactl disk delete.
  3. Skipping colima delete entirely and running rm -rf ~/.colima: the data disk file lives inside that directory โ€” more thorough than --data, taking configuration and data alike.

The fix: back up the named volume before any deleteโ€‹

The generic packing method works for any volume, any storage engine:

# Back up: pack the volume contents into the current directory
docker run --rm -v dev-infra_dev-pg-data:/data -v "$PWD":/backup alpine \
tar czf /backup/dev-pg-data-$(date +%F).tgz -C /data .

# Restore: let compose recreate the empty volume first, then unpack
docker run --rm -v dev-infra_dev-pg-data:/data -v "$PWD":/backup alpine \
sh -c 'cd /data && tar xzf /backup/dev-pg-data-2026-10-19.tgz'

For databases, prefer a logical backup โ€” cleaner than copying the data directory and stable across versions:

# Back up (life is the actual database name in this environment โ€” use yours)
docker exec dev-pg pg_dump -U postgres -Fc life > life-$(date +%F).dump

# Restore
docker exec -i dev-pg pg_restore -U postgres -d life < life-2026-10-19.dump

Often the real motive behind a delete is "the disk is full" โ€” a path that needs no delete at all:

  • Reclaim at the container layer: docker system prune
  • Shrink the sparse file: colima ssh -- sudo fstrim -a (v0.5.0+ also releases unused space on restart)
  • The disk can only grow, never shrink: edit disk: in ~/.colima/default/colima.yaml, then colima restart (automatic since v0.5.3)

A four-step pre-delete checklist:

  1. colima version โ€” confirm 0.9.0 or newer; otherwise treat it as the old architecture and back up everything
  2. Re-check the command for --data
  3. Verify the backup on disk (tar -t listing or pg_restore --list reads back)
  4. Note the compose project name โ€” it prefixes the volume name (dev-infra_dev-pg-data comes from the dev-infra directory)

Unrelated but in the same neighborhood: local Dockerized databases have another class of pitfall where a silently occupied port makes you connect to the wrong instance โ€” see Two WSL2 + Docker networking traps.

Watch out

  • colima delete --data is irreversible. There is no recycle bin.
  • On colima 0.8.x and earlier, a plain colima delete is equally irreversible.
  • Do not use rm -rf ~/.colima as a "reset" โ€” on the data-disk architecture it equals --data plus losing your configuration.

FAQโ€‹

Does colima delete remove Docker volumes?โ€‹

Not since v0.9.0. Container data sits on a dedicated data disk that a plain colima delete leaves untouched โ€” the data comes back on the next colima start. Only colima delete --data wipes that disk, and that is irreversible.

Where does Docker store named volume data on a Mac with colima?โ€‹

Inside the colima VM's data disk image: ~/.colima/_lima/_disks/colima/datadisk. On the machine tested here it is a 100 GiB sparse file with an actual usage of about 1.2 GiB, mounted inside the VM at /var/lib/docker. Back up volume contents with tar rather than handling the image file directly.

Why is Docker taking up so much disk space on macOS?โ€‹

Separate displayed size from real usage: the datadisk shows 100 GiB but du measures about 1.2 GiB. Clean up with docker system prune, then run colima ssh -- sudo fstrim -a to shrink the sparse file (v0.5.0+ also reclaims unused space on restart). The disk can only grow, never shrink: raise disk in colima.yaml and run colima restart (automatic since v0.5.3).

How do I back up and restore a Docker named volume?โ€‹

Pack it with a one-off alpine container: docker run --rm -v VOLUME:/data -v "$PWD":/backup alpine tar czf /backup/vol.tgz -C /data . โ€” swap tar czf for tar xzf to restore. For databases like PostgreSQL prefer a pg_dump logical backup; it is cleaner than copying the data directory and survives version upgrades.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

Airflow 3 password reset not working? It reads a JSON file

ยท 5 min read

After updating a user password on Airflow 3, requests to /auth/token with the new password still return 401 โ€” while the password hash in the database verifiably holds the new value.

Encountered this while building AI Ops โ€” LLM-powered analytics that surfaces market trends, user behavior, and sales data for precise operational strategy. The platform's DAG trigger chain rides on this Airflow JWT auth, so a stuck password rotation left the pipeline authorization dangling.

Symptom: password changed, /auth/token still answers with the old oneโ€‹

The new password gets 401 from /auth/token while the old one still gets 201 โ€” every modification step "succeeded", yet the password in effect never changed. This particular rotation was incident response: the old credential had leaked, so every minute of "changed but not effective" was exposure.

The first reflex is the official CLI:

$ airflow users reset-password -u apiuser -p <new>
AttributeError: 'AirflowSecurityManagerV2' object has no attribute 'find_user'

The error points into the FAB (Flask-AppBuilder) auth stack, which smells like a 3.x version bug. CLI broken? Fine โ€” bypass it and update the database directly. That detour set up an even deeper trap.

Root cause: SimpleAuthManager never reads the database โ€” the password lives in passwords.jsonโ€‹

This deployment's auth manager is not the FAB the error implies, but SimpleAuthManager โ€” one command reveals it:

airflow config get-value core auth_manager
# airflow.api_fastapi.auth.managers.simple.simple_auth_manager.SimpleAuthManager

Three layers, and the symptom explains itself:

  • The CLI error is a red herring. The airflow users CLI family belongs to the FAB auth stack; on a SimpleAuthManager deployment its code path crashes with AttributeError. The AirflowSecurityManagerV2 class in the message does exist (as a leftover component), but it has nothing to do with the manager actually handling auth.
  • ab_user is a leftover table. Deployments upgraded from Airflow 2.x carry FAB's user tables. Writing directly โ€” UPDATE ab_user SET password=... with a werkzeug generate_password_hash scrypt hash โ€” returned rowcount=1, and check_password_hash confirmed the stored hash matched the new password. Yet /auth/token kept answering 401: the table genuinely changed; the auth flow simply never reads it.
  • The real source is a JSON file. SimpleAuthManager takes user passwords from the file pointed to by AIRFLOW__CORE__SIMPLE_AUTH_MANAGER_PASSWORDS_FILE โ€” a flat mapping:
{
"apiuser": "<password>",
"admin": "<password>"
}

The username-to-role mapping is declared separately via AIRFLOW__CORE__SIMPLE_AUTH_MANAGER_USERS (e.g. apiuser:admin,admin:admin). The first move in incidents like this should be asking "which manager owns auth?", not patching the symptom "auth is broken".

The fix: edit passwords.json, then force-recreate the containerโ€‹

Three steps:

  1. Edit the host-side passwords.json (the source file mounted into the container):
python3 - <<'EOF'
import json
d = json.load(open('/root/workspace/ai_dag/deploy/passwords.json'))
d['apiuser'] = '<new password>'
json.dump(d, open('/root/workspace/ai_dag/deploy/passwords.json', 'w'), indent=2)
EOF
  1. Recreate the api-server container. This step is not optional โ€” the password file is read only at startup, so editing it does nothing to the running process:
cd /root/workspace/ai_dag/deploy
docker compose up -d --force-recreate airflow-api-server
  1. Once the service is up, verify in both directions โ€” the new password must pass AND the old one must fail; both assertions matter:
# health: back to 200 within ~30s of the recreate
curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/api/v2/monitor/health

# new password โ†’ expect 201
curl -s -o /dev/null -w '%{http_code}' -X POST http://localhost:8080/auth/token \
-H 'Content-Type: application/json' \
-d '{"username":"apiuser","password":"<new>"}'

# old password โ†’ expect 401
curl -s -o /dev/null -w '%{http_code}' -X POST http://localhost:8080/auth/token \
-H 'Content-Type: application/json' \
-d '{"username":"apiuser","password":"<old>"}'

On this incident the results were 201 for the new password, 401 for the old โ€” rotation closed. Verifying only "the new password works" without "the old one fails" is the most common loose end in credential rotation.

Watch out

  • Identify the auth manager before touching anything: the output of airflow config get-value core auth_manager decides where the password lives โ€” FAB keeps it in the database, SimpleAuthManager in a file. Completely different paths.
  • Editing the password file demands a container recreate: the file is read only at startup, and docker compose restart won't reload it.
  • Services depending on that auth must pick up the new password too and restart โ€” otherwise the pipeline sits in a window where the old password 401s and the new one isn't wired in.
  • Recreating the api-server costs seconds to half a minute of downtime โ€” do it off-peak, and poll health until it returns 200 before verifying.

FAQโ€‹

Why does the reset-password command fail after upgrading to Airflow 3?โ€‹

On 3.x deployments running SimpleAuthManager, the FAB airflow users CLI is gone for good โ€” it crashes with AttributeError: 'AirflowSecurityManagerV2' object has no attribute 'find_user' (verified). Run airflow config get-value core auth_manager first to see which manager actually handles auth.

Where does SimpleAuthManager store user passwords?โ€‹

In a passwords.json file (flat JSON like {"username": "password"}) pointed to by AIRFLOW__CORE__SIMPLE_AUTH_MANAGER_PASSWORDS_FILE. The file is read only at container startup โ€” after editing it you must run docker compose up -d --force-recreate airflow-api-server.

Why doesn't updating the ab_user table change the password?โ€‹

ab_user belongs to the FAB auth manager. On deployments migrated to SimpleAuthManager it is leftover data the auth flow never reads โ€” we wrote a scrypt hash with rowcount=1 and /auth/token still returned 401.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

PostgreSQL fe_sendauth in Docker? exec trust vs TCP auth

ยท 5 min read

On the host that runs the database container, docker exec-ing in and running psql connects with no password at all. Run the same username from another container over TCP and it dies instantly with fe_sendauth: no password supplied.

Encountered this while building AI Ops โ€” LLM-powered analytics that surfaces market trends, user behavior, and sales data for precise operational strategy. Ops scripts inside the orchestration container reach the analytics database cross-container, and a connection string copied from the exec habit tripped on the very first hop.

Symptom: exec connects, TCP answers fe_sendauth: no password suppliedโ€‹

Same host, same database, same user โ€” two paths, two fates. Verified matrix (Airflow container โ†’ PostgreSQL container):

Connection methodResult
docker exec cclhub-db psql -U postgres (in-container socket)Connects, no password
Cross-container TCP, DSN without passwordfe_sendauth: no password supplied
Cross-container TCP, DSN with passwordConnects

If you searched for "fe_sendauth no password supplied", "psql no password error" or "docker postgres connection fails without password" โ€” this is it.

Root cause: socket trust and TCP password auth are two different pg_hba pathsโ€‹

PostgreSQL authentication is matched line by line in pg_hba.conf by connection type, and the official image ships completely different rules for the two paths:

  • docker exec uses the Unix domain socket, covered by a local all all trust-style rule โ€” local socket is trusted, no password asked;
  • Cross-container traffic is TCP (a host-type rule), and the official image defaults to scram-sha-256 / md5 password auth.

So the no-password habit built on exec turns into "no password at all" the moment you switch to TCP โ€” the literal meaning of fe_sendauth: no password supplied is "the server wants a password and the client supplied none".

Worth separating two often-confused errors: no password supplied means no password was provided; password authentication failed means one was, and it was wrong. The former points at the connection string; the latter at the credential itself โ€” different fixes.

The fix: put the password in the DSN, don't copy the exec habitโ€‹

Cross-container scripts use a password-carrying connection string, always:

postgresql://postgres:<password>@<db host>:5432/<db>

The recommended source for the password is the DB container's own environment โ€” the official image's POSTGRES_PASSWORD exists precisely for initialization โ€” avoiding a second hardcode:

PW=$(docker exec cclhub-db printenv POSTGRES_PASSWORD)
psql "postgresql://postgres:${PW}@localhost:5432/postgres" -c "SELECT 1"

Application-side (Python here) it's the same shape, with the DSN in environment management:

import os
import psycopg

DSN = os.environ["APP_DB_DSN"] # postgresql://user:pass@host:5432/db
with psycopg.connect(DSN) as conn:
conn.execute("SELECT 1")

Note that passwords containing reserved characters like @ : / # must be percent-encoded in the URL โ€” another place special characters bite; avoiding them in generated database passwords removes an entire class of trouble.

Boundary casesโ€‹

  • The error's shape varies by client: an interactive libpq terminal (psql without -t) first prompts Password for user postgres: and then fails with fe_sendauth; connection pools and GUI tools (pgAdmin) surface it as an auth failure in the UI โ€” different texts, same root cause.
  • .pgpass files and the PGPASSWORD environment variable are two alternative ways to supply the password; in containerized setups, DSN/env injection is more common than mounting a .pgpass file.
  • You can set pg_hba to trust for TCP too โ€” technically possible, and wrong for production: anything that can reach the port gets credential-free access.
  • Auth method version drift: newer official images default to scram-sha-256; very old client libraries may not support it โ€” that's a different error class (unsupported authentication method), not "no password supplied".

Watch out

  • Diagnose the connection path first: socket or TCP, and which pg_hba rule it matches, decides whether a password is even requested โ€” don't generalize exec behavior to everything.
  • Keep the error semantics straight: no password supplied (missing) and authentication failed (wrong) lead to completely different fixes.
  • Avoid or percent-encode special characters in DSN passwords โ€” URL reserved characters silently change how the string parses.

FAQโ€‹

What does fe_sendauth: no password supplied mean?โ€‹

The server's pg_hba.conf requires password auth, but the client's connection string carries no password. It is not "wrong password" (that's authentication failed) โ€” it's "no password at all"; check whether the DSN is missing its password part.

Why does docker exec psql connect without a password?โ€‹

Inside the container psql uses the Unix domain socket, which pg_hba covers with a trust rule; cross-container traffic is TCP and hits a host rule that demands a password. Same command, different path, completely different auth requirements.

How should containerized scripts connect to PostgreSQL?โ€‹

Use a DSN with an explicit password โ€” postgresql://user:password@host:5432/db โ€” read from the DB container's POSTGRES_PASSWORD environment variable. Don't hardcode it and don't expect socket trust to apply over TCP.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

Docker Volume Mounted but Empty? etcd Data Lived in the Writable Layer, Lost on Recreate

ยท 6 min read

During a disk-cleanup pass, docker ps -as showed the etcd container's writable layer at 385MB โ€” while its mounted data volume held just 8K. We didn't dare touch it during cleanup: one recreate, and every piece of Milvus metadata would evaporate with the writable layer.

Encountered this while building AI Customer Service โ€” a 24/7 AI support agent answering product questions; its knowledge-base retrieval runs on Milvus, and all of Milvus's metadata lives in this etcd.

TL;DRโ€‹

compose's volumes: only guarantees "the volume is mounted at this path" โ€” where the app writes is decided by its own parameters. etcd without a data-dir defaults to default.etcd under its working directory: it never used the /etcd mount, and all 385MB sat in the writable layer, one docker compose up -d rebuild away from oblivion. The fix follows etcd's native migration path: online snapshot โ†’ restore โ†’ swap data during a brief stop โ†’ add ETCD_DATA_DIR โ†’ recreate with the volume. Zero data loss, under two minutes of downtime.

Symptomsโ€‹

The etcd service in compose looks "correct" โ€” the volume is declared:

  etcd:
image: quay.io/coreos/etcd:v3.5.5
environment:
- ETCD_AUTO_COMPACTION_MODE=revision
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
# ... nothing about data-dir
volumes:
- etcd_data:/etcd

But two numbers disagree:

$ docker ps -as --format "{{.Names}}\t{{.Size}}" | grep etcd
rag-service-etcd-1 385MB (virtual 199MB) โ† writable layer: 385MB

$ docker exec rag-service-etcd-1 du -sh /etcd
8K /etcd โ† the mounted volume: empty

$ docker exec rag-service-etcd-1 ls -la / | grep etcd
drwx------ 3 root root 4096 default.etcd โ† the data is here: container root

Root Causeโ€‹

Mounted โ‰  used. volumes: etcd_data:/etcd only mounts the volume at the path /etcd; where etcd writes is decided by its --data-dir parameter. etcd's default data-dir is default.etcd under the working directory โ€” this compose set neither the ETCD_DATA_DIR env var nor a --data-dir flag, so etcd created default.etcd at the container root and wrote everything into the writable layer. The /etcd mount point had been empty since day one.

The nastiest property of a "decorative volume" is that it's completely symptom-free: the service runs, reads and writes work, dashboards stay green. It only bites at the moment you run docker compose up -d --force-recreate (config change, writable-layer recycling, host migration) โ€” the layer is discarded wholesale and the data vanishes, precisely when you're doing urgent ops work and can least afford a second incident.

Solutionโ€‹

Use etcd's native snapshot migration: the online snapshot guarantees consistency, and downtime only happens at the final data swap.

Step 1: Consistent online snapshotโ€‹

docker exec rag-service-etcd-1 sh -c \
'ETCDCTL_API=3 etcdctl --endpoints=http://127.0.0.1:2379 snapshot save /tmp/etcd-snap.db'
docker cp rag-service-etcd-1:/tmp/etcd-snap.db /root/etcd-snap.db

snapshot save is safe against a running etcd (it goes through the Raft backend, not file copying) โ€” no stop, no write lock.

Step 2: Restore into the target data-dir structureโ€‹

docker run --rm -v /root:/host quay.io/coreos/etcd:v3.5.5 \
etcdctl snapshot restore /host/etcd-snap.db --data-dir /host/etcd-restored

Restore produces a full member/ data directory (a raw snapshot file cannot be used as a data-dir directly).

Step 3: Brief stop, move data into the volumeโ€‹

docker stop rag-service-etcd-1
rm -rf /var/lib/docker/volumes/etcd_data/_data/* # volume is empty; clear mount residue
cp -a /root/etcd-restored/. /var/lib/docker/volumes/etcd_data/_data/

Step 4: Add the missing config, recreate with the volumeโ€‹

  etcd:
environment:
- ETCD_DATA_DIR=/etcd # โ† the missing line
# ...
volumes:
- etcd_data:/etcd
docker compose up -d etcd    # config change triggers recreate; new container uses the volume

Step 5: Verifyโ€‹

docker exec rag-service-etcd-1 etcdctl --endpoints=http://127.0.0.1:2379 endpoint health
du -sh /var/lib/docker/volumes/etcd_data/_data # data should be in the volume
docker ps -as | grep etcd # writable layer should drop to KB scale

After this fix: writable layer 385MB โ†’ 8KB, 123MB of data living on the volume, Milvus reconnected automatically with metadata reads and writes healthy.

Notes

  • When auditing stateful containers (etcd/postgres/redis/minio), make "writable layer size vs volume size" a standing check: an inflated SIZE in docker ps -as with an empty volume almost always means data isn't on the volume.
  • To find where data actually lives, trace the path the process really reads and writes (docker top for args, look for data dirs inside the container) โ€” never trust the mere presence of a volumes: line; declared is not used.
  • Single-node etcd snapshot restore regenerates member metadata and is only valid for single-node setups; multi-node cluster migrations go through member change procedures instead.
  • The same inspection method appears in Container Logs Filling Your Server Disk? docker system df 'Reclaimable' Lies โ€” docker ps -as writable-layer watching is the same knife; and for the other flavor of mount surprise, see Docker Volume Override Bind Mount.

FAQโ€‹

Why is my Docker volume mount empty?โ€‹

Two usual causes: an empty volume shadows whatever the image had at that path (documented Docker behavior); or the application's data-directory setting never pointed at the mount, so data went to the container's writable layer โ€” the etcd case in this post. du on the volume vs the writable layer tells them apart instantly.

How do I safely migrate etcd to a new data-dir?โ€‹

etcdctl snapshot save for a consistent online snapshot (no downtime), etcdctl snapshot restore --data-dir to build a directory with proper member structure, stop the container, place the data, start with the new data-dir, then verify with endpoint health plus upstream reconnection. Downtime is only the swap itself.

I declared a volume in compose โ€” why isn't it used?โ€‹

volumes: mounts the volume at a container path; the application decides where to write from its own config โ€” etcd's data-dir, postgres's PGDATA, redis's dir. When the mount point and the app config disagree, the volume is an empty directory and all data sits in the writable layer, lost on recreate.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

Container Logs Filling Your Server Disk? docker system df 'Reclaimable' Lies

ยท 6 min read

The alert email: production server root partition at 81% (30G/40G, past the 80% red line). First instinct: check docker system df โ€” and there it is, images at RECLAIMABLE 100% (7), apparently a quick win. Except all 7 images are running; following the hint with docker image prune -a would be a production incident.

Encountered this while building AI Analytics โ€” an LLM-powered analytics platform that surfaces market trends, user behavior, and sales data; the disk in question belongs to the Docker server running its Airflow data pipeline.

TL;DRโ€‹

Past a disk red line, don't trust docker system df RECLAIMABLE โ€” it's an estimate of "space with no container reference", and active images get flagged 100% anyway. The right move: sudo du -xh -d1 / layer by layer. This incident's three invisible hogs were none of them business data: task logs accumulating in container writable layers (no log volume in the Dockerfile), package-manager caches (npm + pnpm, ~4G combined), and a backup script that never pruned (full clones every run). Fixes: delete caches, reclaim writable layers with force-recreate, add TTL pruning to the backup script โ€” 81% back down to 64%.

Symptomsโ€‹

$ df -h /
Filesystem Size Used Use% Mounted on
/dev/vda1 40G 30G 81% /

$ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 7 7 4.2GB 100% (7) โ† all running
Containers 5 5 810MB 0%

Acting on docker system df (clean images) is a dead end โ€” RECLAIMABLE says 100% but ACTIVE says 7/7. Where the space actually went, docker system df never shows:

sudo du -xh -d1 / | sort -rh | head
# selected output:
# 2.7G /root/.npm โ† npm cache
# 1.1G /root/.local/share/pnpm โ† pnpm store
# 857M /root/backups-git โ† backup clones, never pruned
# (hidden in overlay2: airflow scheduler writable layer 468M + dag-processor 257M)

Root Causeโ€‹

Three kinds of consumption, all invisible from the "business data" perspective.

Writable layers eating logs. Airflow task logs are written inside the containers with no external volume โ€” scheduler writable layer 468M, dag-processor 257M, ~780M accumulated in two weeks, monotonically growing. Image layers never change; the writable layer does. docker system df buries it in the Containers SIZE total (810M), where it has no presence.

Package-manager caches only grow. On a server with frequent deploys/builds, ~/.npm (2.7G) and the pnpm store (1.1G) pile up indefinitely; nobody ever cleans them.

A backup script that never prunes. The backup script clones the repo worktree in full and pushes to GitHub every run โ€” old clone directories are never removed, so 857M is mostly historical duplicates. Sneakier: orphan clones whose branch never pushed successfully can't just be deleted; verify first.

And docker system df RECLAIMABLE is a statistical estimate of "space not referenced by a running container" โ€” active images can display 100% reclaimable (all 7 of ours did). It's a false-positive generator, not a cleanup guide.

Solutionโ€‹

Step 1: Locate with du, layer by layer โ€” look before deletingโ€‹

sudo du -xh -d1 / | sort -rh | head        # root partition, level by level
sudo du -xh -d1 /var/lib/docker | sort -rh | head # drill into Docker's dir
docker ps -as --format "table {{.Names}}\t{{.Size}}" # per-container writable layer

du -x stays on one filesystem, avoiding /proc, /sys noise and overlay confusion; docker ps -as SIZE exposes each container's writable layer โ€” the key command for the "logs written inside the container" family.

Step 2: Delete caches outrightโ€‹

npm cache clean --force        # or simply rm -rf ~/.npm/_cacache
pnpm store prune # removes only unreferenced packages

~5.1G reclaimed, zero risk โ€” caches re-download on demand.

Step 3: Reclaim writable layers with force-recreateโ€‹

docker compose up -d --force-recreate   # writable layer goes away with the old container

~780M reclaimed here. Two preconditions: pick a low-traffic window (services restart), and rescue anything valuable first โ€” e.g. docker cp the task logs out, or they vanish with the container.

Step 4: TTL for backups, prevent recurrenceโ€‹

# keep backup dirs for 7 days, prune older ones
find /root/backups-git -maxdepth 1 -type d -mtime +7 -exec rm -rf {} +

Add the pruning to the tail of the backup script (deployed in our github-backup-push.sh); before deleting, check for orphan clones whose branch never pushed (git ls-remote to compare) and confirm no unique commits โ€” our 325M of orphans were removed only after verification.

After cleanup: 81% โ†’ 64%, with caches + pruning + writable layers together reclaiming ~6.7G.

Notes

  • docker system df RECLAIMABLE โ‰  deletable: active images can be flagged 100% (all 7 of ours were). Decide from du + docker ps -as measurements.
  • force-recreate restarts services and destroys writable layers โ€” docker cp out any logs you need first. The real fix is an external log volume with retention rotation; writable-layer recycling is this incident's stopgap.
  • Always check for orphan backups before deleting: branches that never pushed successfully โ€” verify with git ls-remote first.
  • Pair disk red-line alerts with the locating command: the first action on alert should be du -xh -d1 /, not guessing.
  • For the earlier incident on the same server (disk 93% + CPU 160%), see Debugging a 2-core/7G Docker Server Resource Black Hole.

FAQโ€‹

docker system df shows 100% RECLAIMABLE โ€” can I just delete?โ€‹

No. RECLAIMABLE estimates "space with no container reference", and running active images can still be flagged 100% reclaimable โ€” all 7 of ours were. It answers "how much is theoretically unreferenced", not "what can be deleted". Measure first with du -xh -d1 and docker ps -as.

What's the difference between docker ps SIZE and docker system df SIZE?โ€‹

docker ps -as SIZE is the per-container writable layer; docker system df is the category-level aggregation over images/containers/volumes/cache. Logs accumulating inside a container only ever appear in the writable layer (visible via docker ps -as), never in any image size โ€” which is exactly why "images look small but disk keeps growing".

How do I clean up a Docker server running out of disk?โ€‹

Three categories: package-manager caches deleted outright (npm cache clean --force, pnpm store prune), zero risk; container writable layers reclaimed via docker compose up -d --force-recreate (service restart; rescue logs first); backups, logs, and clone directories put on TTL pruning to prevent recurrence. Before any deletion, confirm the hogs with du -xh -d1 /.

CCLEE

Independent developer, 24 years in e-commerce, focused on grounding AI in real business scenarios.

Work with me

Docker Compose service won't come back after restart? Check the restart policy

ยท 5 min read

Debugging a Milvus-dependent service that failed to start in a RAG knowledge base project โ€” full writeup below.

TL;DRโ€‹

After a host reboot (or a container crash), a group of services didn't come back: the app port had no listener and docker ps -a showed everything Exited. The root cause: docker-compose.yml had no restart policy (default no), so once a container died it stayed dead. Fix: set restart: always on every production service so the infrastructure self-heals after a crash or reboot.

Two WSL2 + Docker Networking Pitfalls: Silently Occupied Ports & Host Mode localhost Unreachable

ยท 5 min read

TL;DRโ€‹

Two common networking pitfalls with WSL2 + Docker Desktop:

  1. Silently occupied port: When a Docker container maps 5432, SSH tunnel localhost:5432 connects to the container's PostgreSQL instead of the remote server โ€” the password is correct, but you're hitting the wrong instance
  2. Host mode localhost unreachable: network_mode: host shares the Docker utility VM's network, not WSL2's โ€” curl localhost:8080 fails

Container Port Unreachable from WSL2? The Docker Desktop network_mode:host Trap

ยท 3 min read

Encountered this issue while building an AI data analytics platform (Airflow + PostgreSQL) for a client. Here's the root cause and solution.

TL;DRโ€‹

On Docker Desktop for Windows (WSL2 backend), network_mode: host container ports are unreachable from the WSL2 host. The container shows the port listening, but curl localhost:PORT returns connection refused. The fix: use network_mode: !reset in your override file to remove host mode, then switch to bridge + external network + port mapping.

WordPress Block Theme Changes Not Taking Effect? FSE Guide

ยท 8 min read

Encountered these six issues repeatedly while developing WordPress Block Themes for clients. Each one took significant debugging time. This guide covers the root causes and provides ready-to-use solutions.

TL;DRโ€‹

Six issues ranked by frequency: file changes not applying (database cache overrides files), block nesting errors (unclosed comments), child theme content not rendering (missing post-content block), SVG icons disappearing (WP_Filesystem polluted by plugins), WP-CLI mail failures (SMTP plugins don't hook in CLI), and gallery images not loading (lazy loading conflicts with the slider). Each scenario includes copy-paste diagnostic commands.