Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Container updates

How to Update Nextcloud in Docker Safely

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Update Nextcloud in Docker by replacing the container, not by modifying the running container: back up the application and database, pull the intended image, stop and remove the old container, then start a new container with exactly the same persistent mounts, ports, environment variables, and other runtime options. With Docker Compose, run docker compose pull followed by docker compose up -d. The image startup process detects the version stored in the persistent volume and runs the upgrade when the image version differs.

What actually happens during a Docker update

A Nextcloud Docker update has two separate parts:

  • Container replacement: Docker downloads a new image and creates a new container from it. The old container is disposable.
  • Nextcloud application upgrade: At startup, the image compares the Nextcloud version in the persistent installation volume with the version inside the image. If they differ, the startup process begins the Nextcloud upgrade.

The official Docker workflow describes this as pulling the new image, throwing away the old container, and starting a new one. Recreating a container does not erase a named volume or host bind mount by itself, but the new container must be given every volume that the old container used. If a mount is omitted, Nextcloud can start with missing configuration, an empty data directory, or no custom applications.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before you update: a safety checklist

Do not begin with docker pull. First establish which version you have, where its state is stored, and whether the target release is an allowed upgrade.

1. Record the current deployment

  • Write down the container or Compose service name.
  • Capture the complete docker run command, or save the Compose file and its environment file.
  • List every volume and bind mount, including the database mount, custom application directories, themes, and external storage.
  • Record published ports, networks, restart policy, user settings, proxy-related variables, and image tag.

The replacement container must reproduce these settings. A common update failure is not the image itself but an omitted environment variable, port, network, or mount.

#1 Best Overall
Sale
UGREEN NAS DH2300 2-Bay for Beginners & Personal Users, Phone Backup | AI Album, Private Cloud/Remote Access, File Sharing, Multi-Device Backup, Home Entertainment, 4GB RAM on Board (Diskless)
  • Entry-level NAS Personal Storage:UGREEN NAS DH2300 is your first and best NAS made easy. It is designed for beginners who want a simple, private way to store videos, photos and personal files, which is intuitive for users moving from cloud storage or external drives and move away from scattered date across devices. This entry-level NAS 2-bay perfect for personal entertainment, photo storage, and easy data backup (doesn't support Docker or virtual machines).
  • Set Your Devices Free, Expand Your Digital World: This unified storage hub supports massive capacity up to 64TB.*Storage drives not included. Stop Deleting, Start Storing. You can store 22 million 3MB images, or 2 million 30MB songs, or 43K 1.5GB movies or 67 million 1MB documents! UGREEN NAS is a better way to free up storage across all your devices such as phones, computers, tablets and also does automatic backups across devices regardless of the operating system—Window, iOS, Android or macOS.
  • The Smarter Long-term Way to Store: Unlike cloud storage with recurring monthly fees, a UGREEN NAS enclosure requires only a one-time purchase for long-term use. For example, you only need to pay $459.98 for a NAS, while for cloud storage, you need to pay $719.88 per year, $2,159.64 for 3 years, $3,599.40 for 5 years. You will save $6,738.82 over 10 years with UGREEN NAS! *NAS cost based on DH2300 + 12TB HDD; cloud cost based on 12TB plan (e.g. $59.99/month).
  • Blazing Speed, Minimal Power: Equipped with a high-performance processor, 1GbE port, and 4GB RAM on Board, this NAS handles multiple tasks with ease. File transfers reach up to 125MB/s—a 1GB file takes only 8 seconds. Don't let slow clouds hold you back; they often need over 100 seconds for the same task. The difference is clear.
  • Let AI Better Organize Your Memories: UGREEN NAS uses AI to tag faces, locations, texts, and objects—so you can effortlessly find any photo by searching for who or what's in it in seconds. It also automatically finds and deletes similar or duplicate photo, backs up live photos and allows you to share them with your friends or family with just one tap. Everything stays effortlessly organized, powered by intelligent tagging and recognition.

2. Confirm the current Nextcloud version

Use the Nextcloud command-line tool as the web user and note the reported version. In a Compose deployment:

docker compose exec --user www-data app php occ status

Here, app is the service name used by your Compose file. The Docker README also documents the numeric-user form:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker compose exec -u33 app ./occ

Alpine-based images use UID 82 rather than UID 33. Use the user identity expected by the image so that generated files remain owned by the web user.

3. Check the upgrade path

Nextcloud major versions must be upgraded one at a time. Bring the current major release to its newest point release before moving to the next major release; do not skip a major version. Review the release notes, system requirements, and compatibility of every third-party app before a major upgrade. Maintenance releases are intended to address critical functionality and security bugs, but the newest available tag is not automatically the right target for every installation.

4. Make a fresh backup

Nextcloud’s upgrade guidance recommends maintaining regular backups and making a fresh backup before every upgrade. Back up all of the following:

  • the config directory;
  • the data directory;
  • the custom apps directory, when you use one;
  • the theme directory, when customized;
  • the database, using the database engine’s supported dump or backup procedure.

The database is separate from the application container. Recreating the Nextcloud container is not a database backup and cannot restore database records if the database volume or server fails.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Plan maintenance mode

Maintenance mode locks existing sessions and prevents new logins, reducing the chance of changes during the upgrade. If maintenance mode remains enabled after the new container starts, turn it off only after the upgrade has completed and your checks pass.

Rank #2
Sale
UGREEN NAS DXP2800 2-Bay for Advanced Home Users, Remote Workers & Creators | Home Media & Data Center, Docker & VM, Plex, Fast File Transfer, Intel N100, 8GB DDR5, 2.5GbE, 2x M.2 NVMe, 4K HDMI(Diskless)
  • 【Advanced Home Data & Media Hub】For advanced home users who need phone backup, file storage, and centralized data management. Centralize family photos, 4K videos, movies, computer backups, and personal files in one place while running multiple apps for home entertainment and everyday data management. Suitable for households with growing digital libraries and multiple NAS use cases.
  • 【Built for Creators, Media Servers & Advanced Apps】Powered by the Intel N100 Quad-Core CPU, 8GB DDR5 RAM, 2.5GbE networking, and dual M.2 NVMe slots, DXP2800 handles large files and heavier workloads with ease. Run Docker, virtual machines, and media server applications compatible with Plex—ideal for content creators, tech enthusiasts, and advanced home users managing 4K videos, RAW photos, personal media libraries, and multiple NAS apps.
  • 【Up to 80TB for Growing Digital Libraries】 Supports up to 80TB of storage using two HDD bays and two M.2 NVMe SSD slots for family photos, movies, RAW photos, 4K videos, work files, and device backups. AI photo management supports recognition of people, objects, scenes, and locations, album organization, and duplicate photo detection. HDDs and SSDs are not included.
  • 【AI-powered Home Surveillance】Turn DXP2800 into a centralized home surveillance hub by connecting compatible network cameras and storing recordings locally on your NAS. AI-powered features include Face Recognition, People Detection, and Pet Detection, helping advanced home users review important events more efficiently while managing home surveillance and personal data in one place.
  • 【One data Center Across Your Devices】Keep files from desktops, laptops, phones, tablets, and other devices together instead of scattered across cloud accounts and external drives. Access, back up, organize, and share data across Windows, macOS, Android, iOS, web browsers, and compatible smart TVs—ideal for creators and advanced home users working across multiple devices.

Updating a standalone container created with docker run

Use this method when the installation was created directly with docker run rather than a Compose project.

Step 1: Pull the intended image

docker pull nextcloud

This pulls the image referenced by the nextcloud tag. If your deployment uses a version-specific tag, pull that exact tag instead. Decide the target tag deliberately; a floating tag is convenient, while a pinned tag makes the target explicit and reduces unplanned changes.

Step 2: Stop the old container

docker stop <your_nextcloud_container>

Replace the placeholder with the actual container name. Stopping the container ends the web process before the old definition is removed.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Step 3: Remove only the container

docker rm <your_nextcloud_container>

This removes the container definition. It does not substitute for a backup, and it does not preserve settings that existed only in the old container definition. Keep your named volumes or host directories; they contain the persistent state that the new container must reuse.

Step 4: Recreate it with the original options

docker run <OPTIONS> -d nextcloud

Use the same options as before, changing only the image tag when that is the planned upgrade. In particular, reattach:

  • the persistent /var/www/html volume or bind mount;
  • the separate database connection and database volume or service;
  • published ports and networks;
  • environment variables;
  • restart and user settings;
  • custom application, theme, or storage mounts.

When the container starts, the image startup script compares the version in the persistent volume with the image version and launches the application upgrade if necessary. Do not start a second container against the same data directory while the first one is still running.

Updating a Docker Compose deployment

Compose is usually safer to operate repeatedly because the service definition records mounts, environment variables, ports, networks, and the image reference in one file. That reduces configuration drift between updates.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
BUFFALO LinkStation 210 2TB 1-Bay NAS Network Attached Storage with HDD Hard Drives Included NAS Storage that Works as Home Cloud or Network Storage Device for Home
  • Value NAS with RAID for centralized storage and backup for all your devices. Check out the LS 700 for enhanced features, cloud capabilities, macOS 26, and up to 7x faster performance than the LS 200.
  • Connect the LinkStation to your router and enjoy shared network storage for your devices. The NAS is compatible with Windows and macOS*, and Buffalo's US-based support is on-hand 24/7 for installation walkthroughs. *Only for macOS 15 (Sequoia) and earlier. For macOS 26, check out our LS 700 series.
  • Subscription-Free Personal Cloud – Store, back up, and manage all your videos, music, and photos and access them anytime without paying any monthly fees.
  • Storage Purpose-Built for Data Security – A NAS designed to keep your data safe, the LS200 features a closed system to reduce vulnerabilities from 3rd party apps and SSL encryption for secure file transfers.
  • Back Up Multiple Computers & Devices – NAS Navigator management utility and PC backup software included. NAS Navigator 2 for macOS 15 and earlier. You can set up automated backups of data on your computers.

Step 1: Review the Compose definition

Before pulling, confirm that the file still points to the intended Nextcloud image tag and that the application and database volumes are persistent. Check any .env file used for image tags, passwords, paths, or proxy settings.

Step 2: Pull the new image

docker compose pull

This downloads the image versions selected by the Compose configuration.

Step 3: Recreate services

docker compose up -d

Compose recreates services whose image or configuration changed and leaves persistent volumes attached. The Nextcloud startup process then performs the application upgrade when it detects a version difference.

Step 4: Follow the startup output

docker compose logs -f app

Use the service name from your file instead of app. Watch for database connection errors, permission failures, an incomplete upgrade, or an application that repeatedly restarts. Stop following the logs with Ctrl-C; that does not stop the service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Volumes and paths that determine whether data survives

The Docker image stores the Nextcloud installation and non-database data under /var/www/html. Protect that path with either a named Docker volume or a host bind mount, and keep the database in its own persistent volume or managed database storage.

Data or setting Where it must persist Why it matters during replacement
Nextcloud installation state and configuration Persistent mount at /var/www/html, including config Contains the version marker, configuration, and application state used by the startup upgrade.
User files Persistent data directory or its configured external storage Without the original data path, users can appear to have empty accounts.
Database Separate database volume or database service Accounts, shares, metadata, and settings are not restored by replacing the web container.
Custom applications Custom apps directory and its mount, when applicable Third-party applications may be required for the instance to load correctly.
Theme files Theme directory and its mount, when customized Prevents the custom theme from disappearing after recreation.

Custom mounts under /var/www/html

Custom paths mounted inside /var/www/html are upgrade-sensitive. During an upgrade they can be overwritten or removed unless they are listed in upgrade.exclude. Mount custom storage outside this tree when possible, then configure Nextcloud to use it as external storage. If an in-tree mount is unavoidable, document it, back it up independently, and verify its exclusion settings before changing versions.

Maintenance mode and the occ command

occ is Nextcloud’s command-line administration tool. Run it as the web user rather than as root, because root-owned files can later cause permission errors for the web process.

Rank #4
Sale
UGREEN NAS DH4300 Plus 4-Bay for Beginners, Home Users & Remote Workers | Photo & Video Backup, AI Photo Album, File Hub, Private Cloud & Secure Home Surveillance, 8GB LPDDR4X, 4K HDMI (Diskless)
  • Entry-level NAS Home Storage: The UGREEN NAS DH4300 Plus is an entry-level 4-bay NAS that's ideal for home media and vast private storage you can access from anywhere and also supports Docker but not virtual machines. You can record, store, share happy moment with your families and friends, which is intuitive for users moving from cloud storage, or external drives to create your own private cloud, access files from any device.
  • Smart Photo Backup & AI Album: Automatically back up photos and videos from your phone in real time and keep growing family memories organized with AI-powered photo albums. Semantic search, custom learning, and recognition of people, objects, pets, and similar photos help you quickly find the moments you want. Duplicate photo removal also helps keep your library organized—ideal for families and users with large photo collections.
  • User-Friendly App & Easy Setup: Connect quickly via NFC, set up simply and share files fast on Windows, macOS, Android, iOS, web browsers, and smart TVs. You can access data remotely from any of your mixed devices. What's more, UGREEN NAS enclosure comes with beginner-friendly user manual and video instructions to ensure you can easily take full advantage of its features.
  • More Cost-effective Storage Solution: Unlike cloud storage with recurring monthly fees, A UGREEN NAS enclosure requires only a one-time purchase for long-term use. For example, you only need to pay $629.99 for a NAS, while for cloud storage, you need to pay $719.88 per year, $1,439.76 for 2 years, $2,159.64 for 3 years, $7,198.80 for 10 years. You will save $6,568.81 over 10 years with UGREEN NAS! *NAS cost based on DH4300 Plus + 12TB HDD; cloud cost based on 12TB plan (e.g. $59.99/month).
  • Your Data, You Control:No third-party clouds, no hidden access, UGREEN NAS provides a more secure and private data storage solution. It stores data locally on your private hard drives and does automatic backups. Thus, you can keep full control over it. The advanced encryption is TRUSTe certified in the United States and is awarded the first (and only) ETSI EN 303 645 certification mark for NAS products by TÜV SÜD Group.

Check status before and after the upgrade

docker compose exec --user www-data app php occ status

The status output lets you confirm the installed version and whether the instance is in maintenance mode. Run it again after startup to verify that the target version is actually installed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Disable maintenance mode after a successful upgrade

docker compose exec --user www-data app php occ maintenance:mode --off

Use this only after the upgrade has finished and the application is ready for users. If your image uses Alpine, use the image’s web-user UID (UID 82) rather than assuming UID 33. The equivalent command for a standalone container follows the same pattern with docker exec and the container name:

docker exec --user www-data <your_nextcloud_container> php occ status

Verify the instance before declaring success

A container showing “running” is not enough. Check the application and its dependencies in this order:

  1. Confirm the version: run occ status and compare the reported version with the image tag you selected.
  2. Inspect logs: review the application and database logs for migration errors, permission problems, or repeated restarts.
  3. Open the web interface: sign in with an administrator account and confirm that the dashboard loads without an upgrade warning.
  4. Test a representative file: open an existing file, upload a small test file, and remove the test file if appropriate.
  5. Check background jobs: verify that the configured job mechanism runs and that queued tasks are not accumulating.
  6. Check database connectivity: confirm that pages load, user searches work, and no database connection errors appear in the logs.
  7. Check critical apps: open the applications administration page and test the third-party apps your users depend on.
  8. Check maintenance mode: if it is still enabled, turn it off with the web-user command after the other checks pass.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing an image tag

Tag approach Advantage Risk or operational consequence
Floating tag Convenient; a pull obtains the image currently published under that tag. The target can change between maintenance windows, making the exact upgrade less reproducible.
Pinned version tag Makes the intended Nextcloud release explicit and supports controlled change management. Someone must deliberately edit the tag for future updates and verify each release.

For a production installation, record the selected tag, the date of the backup, and the result of the validation checks. A pinned tag does not create a rollback by itself: rollback requires a tested plan to restore the prior application state and database from backup, then recreate the container with the prior image and mounts.

Apache and FPM images: an architectural choice

Image architecture What it provides What you must provide
Apache-based image Nextcloud plus a web server in the container. Usually only the surrounding network, TLS termination, or reverse proxy required by your deployment.
FPM-based image Nextcloud’s PHP-FPM application process. A separate web server or reverse proxy configured to serve the application and pass PHP requests to FPM.

Do not switch architectures as an incidental part of a routine version update. An FPM deployment has additional proxy, network, and health-check configuration that must be reproduced when the container is recreated.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common failure modes and fixes

The new container shows an empty or fresh Nextcloud

The persistent /var/www/html mount was omitted, changed, or pointed at a new directory. Stop the new container, restore the original mount from your recorded configuration, and start it again. Do not initialize a new instance over the old database while diagnosing the mount.

Users or files are missing but the web page loads

The application volume may be present while the data directory or database is not. Check the data mount, database host and credentials, and the database volume. Restore from the pre-upgrade backup if the original state cannot be reattached safely.

Best Value
Synology 2-Bay DiskStation DS223j (Diskless)
  • Secure private cloud - Enjoy 100% data ownership and multi-platform access from anywhere
  • Easy sharing and syncing - Safely access and share files and media from anywhere, and keep clients, colleagues and collaborators on the same page
  • Automated Backup Protection - Set-and-forget backups for Macs, PCs and mobile devices to multiple destinations including cloud and external drives
  • Home Security System - Record and monitor your property 24/7 with support for multiple IP cameras and remote viewing
  • 2-Year Warranty - Reliable hardware backed by Synology's expert customer support team and ongoing software updates

The container restarts continuously

Read the service logs for database connectivity failures, file ownership errors, an incompatible third-party app, or an interrupted migration. Correct the underlying issue before repeatedly recreating the container.

The upgrade stops with an app compatibility error

Third-party applications can lag behind a major release. Use the supported maintenance procedure to disable or update the incompatible app, following the release requirements for your target version. Do not skip a major version to work around the error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Maintenance mode remains enabled

Confirm that the upgrade process completed, inspect logs for migration errors, then run maintenance:mode --off as the web user. If the command fails, fix the underlying permissions or database problem rather than editing files as root.

Custom storage disappears after an upgrade

A mount located under /var/www/html may have been overwritten or removed during the upgrade. Reattach the storage, review upgrade.exclude, and move custom storage outside the application tree when the deployment allows it.

Rollback and recovery planning

Rollback is a coordinated restore, not simply a change to the image tag. If the upgraded application has damaged data or an incompatible migration, stop the services and follow the backup procedure you tested for your database and files:

  1. Preserve the logs and note the image tag and exact time of the failed upgrade.
  2. Stop the Nextcloud and database services so no new writes occur.
  3. Restore the database backup and the matching config, data, custom-app, and theme state.
  4. Recreate the container with the previous image tag and the original mounts, ports, networks, and environment.
  5. Start the services and verify the version, web access, files, background jobs, database, and critical apps.

The database and file state must correspond to the application version being restored. Keep the failed-upgrade backup until the incident is closed so that you can investigate without overwriting evidence.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Standalone Docker or Compose?

Consideration Standalone docker run Docker Compose
Repeatability Depends on retaining and reusing the complete command line. The Compose file records the service definition and can be reviewed before each update.
Configuration drift Higher risk if options are typed from memory or changed manually. Lower risk when the file and environment values are version-controlled and reviewed.
Volume preservation Reliable only when every original mount is copied to the new docker run command. More reliable when volumes are declared in the project and the same file is used for recreation.
Update command docker pull, docker stop, docker rm, then the original docker run. docker compose pull, then docker compose up -d.

Both methods use the same underlying rule: preserve application and database state, recreate the container with the same runtime configuration, and validate the running instance.

A concise runbook

  1. Check the installed version with occ status.
  2. Confirm that the target is the next permitted major version or a point release in the current major series.
  3. Review release notes, system requirements, and third-party app compatibility.
  4. Back up configuration, data, custom apps, theme, and database.
  5. Record every mount, port, network, environment variable, and image tag.
  6. Pull the target image.
  7. Replace the container, or run the two Compose commands.
  8. Watch logs while the startup upgrade runs.
  9. Check version, web access, background jobs, database connectivity, files, and critical apps.
  10. Disable maintenance mode as the web user if it remains enabled.

Following this sequence makes the update a controlled replacement of an ephemeral container while preserving the state that belongs to Nextcloud and its database.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Container updatesDockerDocker ComposeLinux administrationNextcloudself-hosting

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.