DockHosting Docs

Environment variables & storage

Set config and secrets, and keep files across redeploys with persistent volumes.

Setting environment variables

Add environment variables in a project's Settings in the dashboard. They're available to your process at runtime the normal way for your language — process.env.NAME in Node, getenv('NAME') or Laravel's env('NAME') in PHP, os.Getenv("NAME") in Go, and so on.

A new value takes effect on the next deploy or restart — running containers don't pick up a changed variable without one.

Variables DockHosting sets for you

  • PORT — the port your app should listen on
  • Database connection strings, for any database attached to the project — see Databases

Persistent volumes

A container is disposable — it's replaced on every deploy. Anything written to its filesystem that isn't on a mounted volume is gone the moment that container is swapped out.

Mount a volume at a path in your project's settings (commonly storage/ for Laravel, or wherever your app writes uploads, a SQLite file, or a cache) and its contents survive every redeploy — the new container mounts the same volume the old one used.

This works for any runtime, including custom Dockerfiles — it's not framework-specific.

What not to persist

Compiled caches that depend on the exact code version (Laravel's compiled view/config cache is the common example) can go stale across a redeploy if they're on a persistent volume and the new code doesn't match what was cached. Clear them explicitly after a deploy if you hit this — see the note in the Laravel guide.

On this page