[Solved] Nextcloud configuration with environment variables

In certain environments like on Docker, Kubernetes or OpenShift applications usually get configured using environment variables. These apps follow The Twelve-Factor App principles.

Is it possible to configure certain settings in Nextcloud like database parameters using environment variables?

1 Like

Does config.php fit your description?

Not really, I’m not talking about a configuration file but about Environment Variables.

I don’t know for sure, but I’m not aware of any environment variables that Nextcloud uses. It just uses a config file like you see above. So apparently Nextcloud fails factor 3 of the twelve-factor app principles. :astonished:

Found the solution: https://github.com/nextcloud/server/pull/3966

1 Like

Where are all environment variables documented? I would like to setup the complete docker nextcloud environment about environment variables.

For docker images, usually you can get that information right on docker hub. Here’s the link to the nextcloud image:


Yes. that’s true, but I don’t want only define environment variables for the installation process. I am looking for environment variables which are equivalent with the settings I can define in the config.php file.

I don’t think Nextcloud uses environment variables, it relies on config.php. Maybe there’s a way to map config.php to point to env vars?

I wish I had found this before I setup my kubernetes deploy to copy the config.php from S3 in an initContainer. :+1:

Oops I was wrong, after reviewing that pull request referenced from a couple years ago, it looks like you can just take any key you can use in config.php and prefix it with NC_ as an environment variable, and that overrides whatever is in config.php. I’m not sure if that’s in the documentation anywhere but that’s what the code does.