Config.php keeps resetting after Docker container restart

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.7.1
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian GNU/Linux 11 (bullseye)
  • Web server and version (e.g, Apache 2.4.25):
    • replace me
  • PHP version (e.g, 8.3):
    • PHP 8.3.23
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • AIO

Summary of the issue you are facing:

I’m trying to make my Nextlcoud accessible via my local network. Currently the only way is nexcloud.mydomain.com. My setup:
mydomain.com → cloudflare → nginx proxy manager (same device as nextcloud instance) → localhost:11000
I’ve set up a proxy host in NPM for nextcloud.local and (for now) added an entry for nextlcoud.local on my desktop’s ‘/etc/hosts’ that points to the local ip of the server.
Then I ran ./occ config:system:set trusted_domains 2 --value nextcloud.local as well as ./occ config:system:set overwritehost --value="".
./occ config:system:get overwritehost outputs nextcloud.mydomain.com, while cat config.php | grep overwritehost says 'overwritehost' => '',.
If I restart the containers all the values are reset no matter the query.

Nextcloud

2025-07-19T17:17:17.670497077Z Trying to fix docker.sock permissions internally...
2025-07-19T17:17:17.721243499Z Creating docker group internally with id 114
2025-07-19T17:17:18.276606396Z WARNING: No memory limit support
2025-07-19T17:17:18.276685859Z WARNING: No swap limit support
2025-07-19T17:17:18.276701377Z WARNING: Support for cgroup v2 is experimental
2025-07-19T17:17:18.339208646Z WARNING: No memory limit support
2025-07-19T17:17:18.339302349Z WARNING: No swap limit support
2025-07-19T17:17:18.339319608Z WARNING: Support for cgroup v2 is experimental
2025-07-19T17:17:18.820694093Z e[0;92mInitial startup of Nextcloud All-in-One complete!
2025-07-19T17:17:18.820781148Z You should be able to open the Nextcloud AIO Interface now on port 8080 of this server!
2025-07-19T17:17:18.820800629Z E.g. https://internal.ip.of.this.server:8080
2025-07-19T17:17:18.820814814Z ⚠️ Important: do always use an ip-address if you access this port and not a domain as HSTS might block access to it later!
2025-07-19T17:17:18.820829740Z 
2025-07-19T17:17:18.820842574Z If your server has port 80 and 8443 open and you point a domain to your server, you can get a valid certificate automatically by opening the Nextcloud AIO Interface via:
2025-07-19T17:17:18.820856462Z https://your-domain-that-points-to-this-server.tld:8443e[0m
2025-07-19T17:17:20.619677059Z ++ head -1 /mnt/docker-aio-config/data/daily_backup_time
2025-07-19T17:17:20.629036640Z + BACKUP_TIME=03:30
2025-07-19T17:17:20.629167028Z + export BACKUP_TIME
2025-07-19T17:17:20.629701970Z + export DAILY_BACKUP=1
2025-07-19T17:17:20.629767081Z + DAILY_BACKUP=1
2025-07-19T17:17:20.636347620Z ++ sed -n 2p /mnt/docker-aio-config/data/daily_backup_time
2025-07-19T17:17:20.639235957Z + '[' '' '!=' automaticUpdatesAreNotEnabled ']'
2025-07-19T17:17:20.639322253Z + export AUTOMATIC_UPDATES=1
2025-07-19T17:17:20.639452290Z + AUTOMATIC_UPDATES=1
2025-07-19T17:17:20.640988115Z ++ sed -n 3p /mnt/docker-aio-config/data/daily_backup_time
2025-07-19T17:17:20.643240325Z + '[' '' '!=' successNotificationsAreNotEnabled ']'
2025-07-19T17:17:20.643324381Z + export SEND_SUCCESS_NOTIFICATIONS=1
2025-07-19T17:17:20.643381010Z + SEND_SUCCESS_NOTIFICATIONS=1
2025-07-19T17:17:20.643845008Z + set +x
2025-07-19T17:17:20.753477606Z [19-Jul-2025 17:17:20] NOTICE: fpm is running, pid 151
2025-07-19T17:17:20.753555827Z [19-Jul-2025 17:17:20] NOTICE: ready to handle connections
2025-07-19T17:17:20.766056707Z [Sat Jul 19 17:17:20.765251 2025] [mpm_event:notice] [pid 146:tid 146] AH00489: Apache/2.4.62 (Unix) OpenSSL/3.3.4 configured -- resuming normal operations
2025-07-19T17:17:20.766145966Z [Sat Jul 19 17:17:20.765423 2025] [core:notice] [pid 146:tid 146] AH00094: Command line: 'httpd -D FOREGROUND'
2025-07-19T17:17:20.778120941Z {"level":"info","ts":1752945440.7775638,"msg":"maxprocs: Leaving GOMAXPROCS=4: CPU quota undefined"}
2025-07-19T17:17:20.778836067Z {"level":"info","ts":1752945440.7781944,"msg":"GOMEMLIMIT is updated","package":"github.com/KimMachineGun/automemlimit/memlimit","GOMEMLIMIT":3580780953,"previous":9223372036854775807}
2025-07-19T17:17:20.779367990Z {"level":"info","ts":1752945440.7785065,"msg":"using config from file","file":"/Caddyfile"}
2025-07-19T17:17:20.782840768Z {"level":"info","ts":1752945440.7822754,"msg":"adapted config to JSON","adapter":"caddyfile"}
2025-07-19T17:17:20.796584252Z {"level":"info","ts":1752945440.7960424,"msg":"serving initial configuration"}
2025-07-19T17:17:50.724814568Z Deleting duplicate sessions

Configuration

Nextcloud

Before restarting containers:

{
    "system": {
        "one-click-instance": true,
        "one-click-instance.user-limit": 100,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "check_data_directory_permissions": false,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwritehost": "nextcloud.mydomain.com",
        "overwriteprotocol": "https",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "nextcloud.mydomain.com",
            "nextcloud.local",
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "31.0.7.1",
        "overwrite.cli.url": "https:\/\/nextcloud.mydomain.com\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "updater.release.channel": "stable",
        "updatedirectory": "\/nc-updater",
        "loglevel": "2",
        "log_type": "file",
        "logfile": "\/var\/www\/html\/data\/nextcloud.log",
        "log_rotate_size": "10485760",
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "preview_max_x": "2048",
        "preview_max_y": "2048",
        "jpeg_quality": "60",
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\Image",
            "2": "OC\\Preview\\MarkDown",
            "3": "OC\\Preview\\MP3",
            "4": "OC\\Preview\\TXT",
            "5": "OC\\Preview\\OpenDocument",
            "6": "OC\\Preview\\Movie",
            "7": "OC\\Preview\\Krita",
            "0": "OC\\Preview\\Imaginary",
            "23": "OC\\Preview\\ImaginaryPDF"
        },
        "enable_previews": true,
        "upgrade.disable-web": true,
        "mail_smtpmode": "smtp",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 30",
        "activity_expire_days": "30",
        "simpleSignUpLink.shown": false,
        "share_folder": "\/Shared",
        "one-click-instance.link": "https:\/\/nextcloud.com\/all-in-one\/",
        "upgrade.cli-upgrade-link": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/2726",
        "htaccess.RewriteBase": "\/",
        "files_external_allow_create_new_local": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_CF_CONNECTING_IP"
        ],
        "default_phone_region": "DE",
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "davstorage.request_timeout": 3600,
        "dbpersistent": false,
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "appsallowlist": false,
        "allow_local_remote_servers": true,
        "maintenance_window_start": 100,
        "preview_imaginary_key": "***REMOVED SENSITIVE VALUE***",
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "documentation_url.server_logs": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/5425",
        "data-fingerprint": "c3a770f06ab232615927cfd686599275",
        "app_install_overwrite": [],
        "updatechecker": false,
        "DOMAIN": "nextcloud.mydomain.com"
    }
}

After restarting containers:

{
    "system": {
        "one-click-instance": true,
        "one-click-instance.user-limit": 100,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "check_data_directory_permissions": false,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwritehost": "nextcloud.mydomain.com",
        "overwriteprotocol": "https",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "nextcloud.mydomain.com",
            "nextcloud.mydomain.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "31.0.7.1",
        "overwrite.cli.url": "https:\/\/nextcloud.mydomain.com\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "updater.release.channel": "stable",
        "updatedirectory": "\/nc-updater",
        "loglevel": "2",
        "log_type": "file",
        "logfile": "\/var\/www\/html\/data\/nextcloud.log",
        "log_rotate_size": "10485760",
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "preview_max_x": "2048",
        "preview_max_y": "2048",
        "jpeg_quality": "60",
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\Image",
            "2": "OC\\Preview\\MarkDown",
            "3": "OC\\Preview\\MP3",
            "4": "OC\\Preview\\TXT",
            "5": "OC\\Preview\\OpenDocument",
            "6": "OC\\Preview\\Movie",
            "7": "OC\\Preview\\Krita",
            "0": "OC\\Preview\\Imaginary",
            "23": "OC\\Preview\\ImaginaryPDF"
        },
        "enable_previews": true,
        "upgrade.disable-web": true,
        "mail_smtpmode": "smtp",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 30",
        "activity_expire_days": "30",
        "simpleSignUpLink.shown": false,
        "share_folder": "\/Shared",
        "one-click-instance.link": "https:\/\/nextcloud.com\/all-in-one\/",
        "upgrade.cli-upgrade-link": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/2726",
        "htaccess.RewriteBase": "\/",
        "files_external_allow_create_new_local": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_CF_CONNECTING_IP"
        ],
        "default_phone_region": "DE",
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "davstorage.request_timeout": 3600,
        "dbpersistent": false,
        "mail_sendmailmode": "smtp",
        "mail_smtpauth": 1,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "appsallowlist": false,
        "allow_local_remote_servers": true,
        "maintenance_window_start": 100,
        "preview_imaginary_key": "***REMOVED SENSITIVE VALUE***",
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "documentation_url.server_logs": "https:\/\/github.com\/nextcloud\/all-in-one\/discussions\/5425",
        "data-fingerprint": "c3a770f06ab232615927cfd686599275",
        "app_install_overwrite": [],
        "updatechecker": false,
        "DOMAIN": "nextcloud.mydomain.com"
    }
}

adding another domain is a wrong approach for different reasons… best practice is to adjust dns for local access - see 101: Split-Brain DNS (split-horizon)

2 Likes

Couple things:

  • With the AIO variant of Nextcloud Server, the AIO manager expects to have control over many of the global parameters
  • In most of the Docker install methods (and some of others as well), one cannot look only at the config/config.php. Instead use the occ config:list system command as described in the Admin Manual and the support template. This will will show you the merged config.

For local access with AIO see How can I access locally?

2 Likes