Docker apps & stacks
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
MZPanel runs containerized workloads on your servers two ways: single apps (one
image, one container, with a domain, SSL and a sealed env store) and stacks (a full
docker compose project). You manage both from the fleet Apps workspace
(/apps) or a server’s Apps section (/servers/:id/apps), with one shared
Deploy drawer, and deploy catalog apps from the Marketplace.
Docker apps and compose stacks are on every plan: creating, building (from Git or an
uploaded folder), rebuilding and rolling back an app or stack, its env, an attached database
and auto-deploy on git push. A new app or stack
counts against your plan’s shared quota across all servers: Free 3, Plus 5 per server, Pro and Max
unlimited (over it → 402 app_limit). Pro adds adopting containers, PR previews,
shared variables and path routes. Day-2 actions on what already runs (start, stop, restart, logs, releases,
app.update, domains, app auto-update, delete) are never plan-gated. Registry
connections and image update detection work on every plan.
Everything on this page is a job kind that you can also run over MCP or the REST
API. Call jobs_schema with the kind to get its exact fields, then jobs_create with
{ "id": "<server>", "body": { "type": "<kind>", ... } }, and follow it with
jobs_get. The workflow sections below give the kinds in order.
Deploy an app
Section titled “Deploy an app”From the Deploy drawer pick a server, then a source:
- Catalog: n8n, Ghost, analytics, AI UIs and more. Each entry is a declarative form (fields and requirements) and generated secrets are shown once on the success card.
- Custom image: name, image (
org/image:tag), the container port the domain proxies to (the host port is picked by the engine), env, optional memory limit and volumes. - From Git: see Build from git.
MZPanel starts the container, writes the nginx vhost for the domain and issues SSL.
Volumes are validated: a named volume, or a bind under the app’s data dir
/var/lib/mz/apps/<name>/, never /etc or /root.
Job kind: app.create with name, domain, image, port, plus optional
env (list of KEY=VALUE), memory, volumes and the registry fields below.
Deploy a compose stack
Section titled “Deploy a compose stack”A stack is a docker compose file deployed as a unit. MZPanel validates it first
(docker compose config -q), so YAML errors and missing variables fail before
anything starts. Catalog stacks use a __MZ_PORT__ placeholder for the port the
domain proxies to.
Ports stay private by default. Every published port that names no host IP
(5432:5432, - 6000, a long-syntax entry without host_ip) is bound to 127.0.0.1
on each deploy, so a database or admin service of your stack is not reachable from the
internet; only the domain’s nginx proxy is public. Ports that already name an IP
(0.0.0.0:25:25, [::1]:6001:6001) and expose: are left alone, and the deploy output
lists every port it rebound. To publish ports on all interfaces on purpose, add
x-mz: public_ports: true # top level = the whole stack; inside a service = that service only(or write the host IP explicitly, e.g. 0.0.0.0:25:25). Since agent 0.2.158.
Job kind: stack.deploy with name, domain, port and compose. Edit in place
later with stack.get (returns the live compose) and stack.update.
Private registries
Section titled “Private registries”Save registry logins once under Advanced > Integrations > Container registries
(/connect/registries, every plan) and pick the saved connection in the Deploy
drawer, or paste a username and token for one deploy. Any image-pulling job accepts
registryConnectionId (or registryUser, registryPass, registryServer, and
registrySave: false for a one-off). The agent saves the login per app
(/etc/mz/apps/<name>.docker/) or per stack (.mz-docker/), so later pulls,
rollbacks and update checks keep working, and it never touches /root/.docker. See
Container registries.
Domains
Section titled “Domains”An app can serve several domains. One is the primary; each domain gets its own
server blocks and certificate, and every change is nginx -t checked and reverted on
failure. To change an app’s domain: add the new one, make it primary, remove the old
one.
Job kinds: app.domain-add, app.domain-primary, app.domain-remove (each with
name and domain).
Path routes
Section titled “Path routes”One domain can send a path to another app or stack on the same server, for example
example.com/api/ to an API container while the rest of example.com stays with its
owner (an app, a stack, or a site with allowSite). Paths are lowercase, end with a
slash, and /.well-known/ and /mz-* are reserved. Cross-server traffic is the job of
load balancers. Pro.
Job kinds: route.add (domain, path, targetKind: app or stack,
target, optional strip, websocket, allowSite), route.remove, route.list.
Attach a database
Section titled “Attach a database”app.db-attach creates (or reuses) a MariaDB or PostgreSQL database on the same box
plus a user limited to it, makes the engine reachable from the app’s Docker network,
writes DATABASE_URL and DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD
into the sealed env store, and recreates the app. The password is shown once and never
stored in the job log (the job is refused with 409 server_offline rather than queued).
app.db-detach removes the env keys and keeps the data. Every plan. A build with
db: "auto" attaches one for you before the first start when your code’s manifests name
a Postgres or MariaDB/MySQL driver (see Deploy from a folder).
Before an app with an attached database starts (deploy, rebuild, rollback, restart, env change), the agent waits up to 60 seconds for the database to accept connections, so the app does not crash-loop on its first connect. If the database is still not answering, the job prints a warning and starts the app anyway. Since agent 0.2.158.
Job kind: app.db-attach with name, engine (mariadb or postgres) and
optional db.
Environment variables
Section titled “Environment variables”Set env per app or stack from the Env tab. Values are sealed at rest on the box
(only the key name stays readable) and unsealed into a transient --env-file when the
container runs, so a disk snapshot or backup never leaks them. Values survive rebuilds
and stay out of build logs.
Job kinds: app.env-set, app.env-unset, app.env-list (and the stack.env-*
equivalents). For variables shared across many apps, use project shared variables
instead (Projects); those are applied with projects_env_apply,
not with an env job.
Update an app safely
Section titled “Update an app safely”app.update changes the image, port, env, restart policy, CPU or memory limit, or
volumes while keeping the domains, host port, vhost and SSL. When a vhost fronts the
app, the update is rolling: MZPanel starts a -next container, waits for it to be
healthy (the image’s HEALTHCHECK, else the port answering) for up to
healthTimeout seconds (default 60, 5 to 600), switches nginx to it, then stops the old
one. If the new container never gets healthy, the old one keeps serving and the job
fails with health_check_failed and the new container’s last log lines. Set
recreate: true for single-writer apps that must never run twice on the same volumes.
Stacks update with compose up -d.
Job kinds: app.update (pull: true to fetch the newest image for the same tag),
stack.pull for a stack.
Only one change runs at a time per app or stack. A second job waits up to 10 minutes,
then fails with app_busy or stack_busy.
Image updates and auto-update
Section titled “Image updates and auto-update”A cron on each box checks every 6 hours whether the registry now serves a newer
image for the tag each container runs (a registry HEAD, which doesn’t count against
Docker Hub pull limits). Cards then show Update available, and the alert metric
containers_update_available can notify you. Detection works on every plan.
Opt in to auto-update per app or stack and the same scheduled run applies the
update (a rolling app update --pull, or stack pull). The default is notify only.
App and stack auto-update work on every plan.
Job kinds: docker.update-check (on demand), app.auto-update and
stack.auto-update (name, enabled).
Build from git
Section titled “Build from git”In the Deploy drawer pick From Git to build an app or stack from a repository on the box, then run it. The Builder choice:
- Auto (default): your repo’s Dockerfile if there is one, otherwise Nixpacks (installed on first use) detects the language (Node, Python, Go, Ruby and more).
- Dockerfile or Nixpacks to force one.
Set a build context subdirectory for monorepos and build args (sealed on the
box, masked in logs). Build output streams live. A preflight refuses the build on a
box with less than 1.5 GB RAM or 3 GB free disk unless you force it. Connect repos under
Git providers to build private repositories, and turn on
auto-deploy on push with the per-app or per-stack webhook. Both webhooks work on every
plan; a pull request on them builds a PR preview only on Pro and Max (Free and Plus answer
skipped: tier-required). Its On a new push setting decides what a push does to the app’s
earlier rebuilds: cancel the ones still queued (default), also cancel the one building, or keep
them all (cancel_previous: queued, building, none). A cancelled rebuild ends cancelled
and names the newer commit.
A new app must answer on its port within 60 seconds of its first start, or the
build fails with health_check_failed and the app is left in place: fix the port or the
start command and deploy again with the same name. Listen on 0.0.0.0, not 127.0.0.1.
Job kinds: app.build (name, git or archive, optional branch, dockerfile,
builder, domain, port, env, gitConnectionId, db, force), app.rebuild;
stack.build, stack.rebuild.
Deploy from a folder or your AI agent
Section titled “Deploy from a folder or your AI agent”No Git remote needed: an AI agent (Claude Code, Cursor, …) or a script can ship a local project folder to a server in two calls and get an HTTPS URL back. Needs agent 0.2.144 or newer on the server.
apps_source_upload(POST /v1/servers/{id}/apps/source-upload) returns anuploadIdand a readycurlcommand. Run it from the project root: it packs the folder (without.gitandnode_modules) and uploads it straight to the server (512 MiB compressed at most, valid 15 minutes, single use).apps_deploy(POST /v1/servers/{id}/apps/deploy) withsource: {uploadId}(orsource: {git: {url}}) builds and starts it and answers with the job id, the app name and its URL. Pollapps_deploy_statusuntilcompletedorfailed.
- Instant URL: leave
domainout and the app getshttps://<name>-<first 8 characters of the server id>.<platform domain>right away, with a valid certificate. Pass your owndomaininstead once its DNS points at the server. - Database:
db: "auto"attaches PostgreSQL or MariaDB before the first start when the code needs one; the status shows what was detected and attached. - Failures come back as
failure: {stage, exitCode, logTail, hint}. Fix and callapps_deployagain with the same name. An upload is used once, so upload again first. - Any server:
apps_fleet_source_upload(POST /v1/apps/source-upload) andapps_fleet_deploy(POST /v1/apps/deploy) pick the server for you (most free RAM among the online servers matchingplacement: {tags, region}) and say why. - Safe defaults: a new app gets an uptime monitor on its URL, a container alert rule
on its server and a daily backup job once its first build completes, each skipped with a
note when the plan or setup doesn’t allow it. Pass
defaults: falseto skip them.
Full walkthrough: Deploy code from your AI agent.
Releases and rollback
Section titled “Releases and rollback”Each successful build or update is kept as a release. Roll back from the
Releases view; it reuses the built image, so there is no rebuild. Rollback does not
undo database or volume changes made since. A rollback needs the opt-in token scope
backups:restore when run over the API.
Job kinds: app.releases, app.rollback; stack.releases, stack.rollback.
PR preview environments
Section titled “PR preview environments”Git-built apps and stacks can get a throwaway preview per pull request, torn down when the PR closes. Pull requests from forks are ignored on purpose. Pro limits: 10 previews per server (Pro), 50 (Max). See Staging & deploys. On agent 0.2.145+, an app preview whose server has a tag can build on the least-loaded server with the same tag instead (stacks stay put); see Staging & deploys.
Job kinds: app.preview-create, app.preview-destroy, app.preview-list (and
stack.preview-*).
Adopt containers started outside MZPanel
Section titled “Adopt containers started outside MZPanel”Containers and compose projects started by hand (docker run, docker compose up)
show as External. Adopt into mzpanel gives them lifecycle controls, backups and
updates without recreating them unless you ask.
Job kinds: app.adopt (container, name, optional domain), stack.adopt
(project, name, optional redeploy).
Tasks inside containers
Section titled “Tasks inside containers”Cron jobs can run inside a container: the Tasks tab on an app or stack drawer adds an mz cron job with a container target, logged like any other cron run. A missing or stopped container is a failed run.
Job kind: cron.add with a container field (needs the opt-in scope
system:admin over the API, because cron runs commands as root).
Observability
Section titled “Observability”- Logs: filter, download, load up to 1,000 lines, or follow live
(
docker.logs-follow).app.logsreturns recent lines. - Health: unhealthy and restarting badges, the failing health-check output and the restart count.
- Stats history: per-container CPU and memory kept for 7 days
(
containers_metrics_history). - Image scan: Scan on the Images tab runs Trivy (installed on first use) and
shows severity counts (
image.scanwithref). Nothing is stored. - Alerts:
containers_unhealthy,containers_downandcontainers_update_availablealert metrics, plusdeploy.failednotifications for every deploy kind.
Backup, move and remove
Section titled “Backup, move and remove”- Backup: stacks and apps back up as a unit (compose or run spec, database dumps and volumes). See Backups.
- Move or clone an app or stack to another server with its data and domains: Moves & clones. Pro.
- Remove:
app.deleteremoves the container, vhost and certificate. It keeps the attached database and named volumes unless you passdropDb/dropVolumes.stack.deleteremoves a stack (named volumes are kept). Over the API both need the opt-in scopesites:delete.
App proxy: reaching admin UIs privately
Section titled “App proxy: reaching admin UIs privately”Admin UIs like phpMyAdmin, pgAdmin and webmail open as real pages on a MZPanel
domain through a reverse proxy that tunnels HTTP over the agent’s WebSocket to the
app listening on localhost on your box. The box opens no public port for it, so its
hostname and IP stay hidden. A proxy session is owner-scoped and time-limited; bulk
data (database export or import) goes through native tools, not the proxy.
Workflow for an AI agent: deploy, wire up, keep updated
Section titled “Workflow for an AI agent: deploy, wire up, keep updated”servers_listto pick the server, thendocker_ps/stacks_listto see what’s there.jobs_schema {type: "app.create"}, thenjobs_createwith the app body. Polljobs_get.- Add a second domain:
app.domain-add. Attach a database:app.db-attach(read the one-time password from the job result and give it to the person). - Set env:
app.env-set, or shared variables withenv_vars_setthenprojects_env_applyif the app is in a project. - Keep it current:
app.auto-updatewithenabled: true. - If a release misbehaves:
app.releases, thenapp.rollback.
Below Pro, the Pro kinds listed at the top of this page return 403 tier_required;
a new app or stack over the plan’s quota returns 402 app_limit; on Free, a write through
a token after the 30-day automation trial returns 402 automation_trial_ended.
docker.exec and interactive shells are never available to API tokens.
Each job maps to an mz command on the box, the same engine the dashboard drives:
mz app create web --domain app.example.com --image ghcr.io/you/web:1.4 --port 3000 --jsonmz app domain-add web www.example.com --jsonmz app db-attach web --engine postgres --jsonmz app update web --pull --health-timeout 120 --jsonmz app auto-update web on --jsonmz app releases web --jsonmz app rollback web --to <seq>mz stack list --jsonmz route add example.com /api/ --app api --jsonPass a sub-action and --json for machine output. See
The mz CLI and the command catalog.
Gotchas & troubleshooting
Section titled “Gotchas & troubleshooting”402 app_limit. Your plan’s Docker apps & stacks quota is used (Free 3, Plus 5 per server). Delete an app or stack, or upgrade. Redeploying, rebuilding or rolling back an existing one still works.403 tier_required. Adoption, PR previews, shared variables and path routes need Pro. Apps, stacks, day-2 control of existing containers, registry connections and update detection work on every plan.registry_login_failed. The registry refused the saved or pasted login. Check the token’s scope (GHCR: a classic PAT withread:packages).health_check_failed. On an update, the rolling update kept the old container: read the log lines in the error, fix the image or raisehealthTimeout. On a new app, nothing answered on its port within 60 seconds: check that it listens on0.0.0.0and the givenport, then deploy again with the same name.app_busy/stack_busy. Another change to the same app is still running. Wait for it.- Build preflight refused. The box is below 1.5 GB RAM or 3 GB free disk. Free space, or force only if the build fits.
- Needs the agent online. Deploy, build, env and proxy actions run through the agent. Jobs sent while it is offline are delivered when it reconnects (within 24 hours), except database attach, which is refused.
Related
Section titled “Related”- Apps: the fleet Docker workspace.
- Projects: environments and shared variables for apps.
- Moves & clones: move an app or stack to another server.
- Container registries · Git providers
- Staging & deploys: atomic releases and previews for sites.