Engineering Notes
DevOps and Incident Response3 min readUpdated

A Django Deployment Lesson: The Container Was Running, but the Media Was Missing

What a media migration taught me about Docker volumes, Django file paths, and verifying a deployment beyond the health check.

Deployment InfrastructureDjangoDockerDokployNginxStorageDevOps
On this page

While moving our education platform's services into a Dokploy-managed deployment, I ran into a problem that looks simple from the outside: the application was running, but some uploaded media was not appearing.

The backend started. The database was connected. The API responded. None of that meant the application's files were where the new container expected them to be. This is the kind of problem that makes deployment work interesting to me, because every individual check passes and the product is still broken.

Code and uploaded files are different things

The Django backend runs in a container with its application under /app. Two directories inside it have very different jobs:

PathContentsHow it gets there
/app/mediaFiles users uploadedWritten at runtime; must persist across deployments
/app/staticfilesCSS, JavaScript, admin assetsGenerated by collectstatic during deployment

If a new container starts with the correct code but without the media volume or the restored files, Django still returns database records that point to images. The records are fine. The files they point to are simply not there.

What I checked

I looked at the filesystem inside the backend container and at the storage mapped to /app/media. I also checked the Django settings for MEDIA_ROOT and MEDIA_URL directly, instead of assuming the paths inside the container matched the paths on the host.

The restore put 16 files, about 17.7 MB in total, into the backend media volume. Once they were present, the media directory showed the expected data, and requests for images through both the API and the frontend paths returned HTTP 200 with an image content type.

That proved the media route I tested was working. It did not prove that every file reference in the database was valid, so individual broken file paths still needed checking one by one.

Why the volume matters

A container's writable filesystem is not a dependable place for user uploads. Containers get rebuilt, redeployed, and replaced, and anything written inside them goes with them. Uploads belong on a persistent volume or a suitable external object store.

The deployment model I use now keeps the application image separate from persistent data:

  1. Browser
  2. Nginx / HTTPS
  3. Next.js frontend, or Django backend
  4. /app/media on a persistent volume, or PostgreSQL (records and file references)
Application containers and persistent storage

PostgreSQL stores the metadata and the file references. The uploaded files themselves still have to exist in the storage location Django reads from.

Static files are a separate check

I also worked through static file handling for the containerized Django deployment. collectstatic put the admin assets under /app/staticfiles, but that is only half of it. The deployment also needs a reliable way to serve /static/, either through correctly configured middleware or a static file-serving layer.

Since then I validate an actual file URL in the browser, not just the collectstatic output or the application's health endpoint.

My checklist for a migration

Before I treat a migration as successful, I verify:

  • the application process is running
  • an API request returns real data
  • the database is connected
  • the Django settings are the ones I expect
  • the media volume contains the files
  • static files are served
  • the URLs a browser actually requests return the right content

A 200 on the homepage is useful, but it does not confirm that the application can serve uploaded resources, save new data, and keep that data after the next redeploy.

Deployment issues often come from the boundaries between systems: host paths and container paths, volumes, proxies, and application settings. A healthy container is not the same as a healthy product. The same lesson showed up in a different form when an API call failed behind a page that loaded fine: When a Next.js Page Loads but Its Django API Call Fails.

Related reading