How to Update PHP-Based Docker Apps on Your Home Server Safely

Eva Wong is the Technical Writer and resident tinkerer at ZimaSpace. A lifelong geek with a passion for homelabs and open-source software, she specializes in translating complex technical concepts into accessible, hands-on guides. Eva believes that self-hosting should be fun, not intimidating. Through her tutorials, she empowers the community to demystify hardware setups, from building their first NAS to mastering Docker containers.

A PHP security patch inside a container normally arrives through a rebuilt image. Downloading that image and putting it into service are separate steps. Your update plan also needs to protect the database and persistent files that outlive the container.

Back up application data, its database where applicable, and configuration before changing the image. Pull a supported patched release, recreate the service, verify the replacement container, and check the critical user action before recording the update as complete.

1. Record the current deployment

Confirm the project directory and service names with docker compose ps. Record current image tags and image IDs with docker compose images, plus where persistent volumes and database state live. Store a protected copy of the Compose configuration without exposing secrets in shared logs.

Check the destination image's release notes for the PHP fix. A tag named latest is not evidence of a particular patch. If you use a digest pin, it must change to the verified replacement digest.

2. Take a consistent backup

Use the application's documented backup method. Preserve configuration, files, and a database backup from a consistent recovery point. Coordinate write suspension or maintenance mode when the application requires it. A filesystem copy of a live database directory is not a universal substitute for a valid database backup.

Keep the recovery copy outside the application's writable reach and know how to restore it. Preserve the prior configuration and image reference, but remember that restoring an old vulnerable image should not put it straight back on the public internet.

Why can an image rollback fail to restore the application?

A container image normally contains executable code, while a database and uploaded files live in persistent storage. An upgrade can change the database schema or rewrite application state. Switching back to the old image then presents old code with new data; the result may be incompatible even though the image starts.

For a stateful app, retain a matched recovery set: the supported database export, configuration, relevant application files, and the old artifact reference. Nextcloud’s backup instructions identify the state required for that application; other apps have their own rules. An image cache alone cannot reconstruct missing or migrated data.

3. Pull and recreate the intended service

For a maintainer-published image, update the service's image reference to a compatible fixed release, then use this example from the correct project directory. Replace app with your PHP application service:

docker compose pull app
docker compose up -d --no-deps app
docker compose ps
docker compose exec -T app php -v

Docker documents that pull downloads images without starting containers; up applies image or configuration changes by recreating containers. Here, --no-deps limits the change to the selected service. Use it only when dependent services are already healthy and compatible.

For custom builds, update the relevant PHP base or packages, rebuild through your normal build pipeline, and deploy the resulting image. Repeat for workers using that runtime. Do not patch an ephemeral container shell and assume the fix will survive recreation.

4. Validate the application before reopening access

Check logs locally for startup errors without sharing tokens or private paths. Confirm the web runtime, then test login, file browsing, a small upload, and a background task. Verify that volume paths and ownership still match the intended layout.

If public access was restricted, restore it only after the version and functional checks pass. A green container status alone does not establish that uploads or background jobs work.

How do you verify the new container without testing the entire server?

Check three layers separately: replacement, runtime, and user behavior. Record the container image identifier after recreation, inspect the runtime in the correct service, then perform one representative critical action. For a file app, read a known test file and, if uploads are essential, upload a small disposable file. A database-dependent error may not appear on a simple landing page.

Failure Likely next investigation
Old image still running Compose project, service selection, and recreation
Runtime changed; app returns errors Extensions, compatibility, configuration, and migrations
Login works; uploads fail Persistent mount permissions, storage, and upload settings
Rollback starts but data errors remain Restore the matched pre-upgrade state according to the app guide

The distinction between pulling images and creating or replacing containers is documented by Docker. Connect the result to runtime identification and recoverable-copy planning so the update record demonstrates more than a successful shell command.

5. Recover deliberately if validation fails

Keep the service isolated while investigating. Restore application files and database state together when the app's migration rules require it; changing only the image can be unsafe after a schema upgrade. Do not use docker compose down -v as a troubleshooting shortcut because it can remove named volumes.

For ZimaCube 2 users, separate the update record from your bulk files and keep independent backups. A successful update ends with a known runtime, working application functions, and a recovery path you can still explain.

Explore ZimaCube 2 Personal Cloud Home NAS for your private storage and self-hosted application setup. Software security depends on the installed services, their configuration, and verified updates.

Continue the PHP security series

Sources and scope

Checked October 22, 2026. Deployment advice must be matched to your application and vendor documentation; these articles do not establish product-specific exposure.

Support & Tips

More to Read

Get More Builds Like This

Stay in the Loop

Get updates from Zima - new products, exclusive deals, and real builds from the community.

Stay in the Loop preferences

We respect your inbox. Unsubscribe anytime.