Memory limit quite low
The php memory_limit is not set and thus defaults to 128M. This results in a crash, when I try to generate thumbnails of photos taken with a standard digital camera usingocc preview:generate-all.
A larger memory limit is required for this standard task. It should be ok to increase it on installations that target only small groups of users.
Possible solutions:
- Explicitly set (a larger) memory_limit in Dockerfile
- Allow to set the memory limit with an ENV var
- Add a php-override.ini and document how to use it. Advantage: This would allow for all kinds of custom tweaks to php.ini
Bump. Having the same issue.
Hi, I have similar errors being thrown in my nextcloud install, any updates / working solutions to this?
What should be the limit in your opinion?
@pierreozoux make it optional with a default (docker ENV) option?
Does anybody want to PR this?
What would be the best workaround until this is implemented? I would like to set it to 512MB
@monreal I used Ansible to update the .htaccess file inside the docker from 512M to 2G after the docker is deployed. Looks like the default is now 512M.
@FriedCircuits for me it is still 128mb with 14rc. Do I have to change it manually in Nextcloud's .htaccess because it was not updated manually? Also I wonder why there is no php.ini at all
So, I actually got memory_limit=512M in my .user.ini I guess occ does not get its setting from there? I noticed when I had to manually create some DB indices after the NC14 upgrade. The occ command worked but printed a warning about the setting being lower than the recommended 512mb. PHP default seems to be 128mb so without a php.ini I guess it is using that...
I am using the fpm-alpine image so i am not sure if it works for all images.
Because both php-cli and php-fpm support variable substitions i would suggest to use a custom /usr/local/etc/php/conf.d/nextcloud.ini with variables which should be changeable by the user. This file could be installed by the Dockerfile.
For Example
nextcloud.ini
memory_limit=${PHP_MEMORY_LIMIT}
Dockerfile
[...]
ENV PHP_MEMORY_LIMIT=512M
COPY nextcloud.ini /usr/local/etc/php/conf.d/nextcloud.ini
[...]
Now the user can run this image with -e PHP_MEMORY_LIMIT=1G and increase the limit.
@ptrunk That would be great and would work better with docker swarm since the container can be rebuilt at anytime. I hope someone at nextcloud can resolve this as it coming up on a year.
The php cli memory_limit problem is apparently fixed now by #460 but i am not sure a hardcoded value of 512M is the way to go because it still could be too low in some cases.
If someone wants to try i have created a custom docker image based on nextcloud:14.0.0-fpm-alpine with an environment variable PHP_MEMORY_LIMIT [1].
docker pull registry.gitlab.com/p7k/docker-nextcloud/nextcloud-fpm:14.0.0-1
I would prefer to have this kind of configuration also for other variables instead of using a .user.ini file but this is just my personal opinion.
[1] https://gitlab.com/p7k/docker-nextcloud/tree/master/fpm
@ptrunk Cool, I may it give it a try. I never could get the FPM to work with nginx/docker-proxy but now I am migrating to traefik so maybe it will work.
In my case 512M isn't enough. I need at least 1G. I can't remember why I was hitting the limit. I have external mounts and elasticsearch setup.
Hello everybody, so, the nextcloud docker-image comes by default with a .user.ini inside the document-root of nextcloud which already has 512M configured. However, just running
docker exec --user 33 -ti nextcloud occ preview:generate-all
is not enough to make use of it - it instead still falls back to the 128M that PHP considers to be default. To actually use .user.ini I came up with the following solution:
docker exec --user 33 -ti nextcloud php -c .user.ini -f occ preview:generate-all
This runs occ inside the container (in my case "nextcloud") as user 33 (which is www-data) but does it in a way so that PHP loads the configuration from .user.ini before. This way, you can configure whatever PHP option you want and it even is persistent if you made /var/www/html a docker-volume. Hope that helps. cheers, chris
I ended up making a new Dockerfile based on the official one. Way better than having to modify the image afterwards everytime time there is an update. I can just run my Ansible playbook to update the Dockerfile and rebuild image.
https://hub.docker.com/r/mobilewill/nextcloud-full-mem2g/
I'm using the "linuxserver/nextcloud" image and I have the same issue. I tried to run
docker exec --user 33 -ti nextcloud php -c .user.ini -f occ preview:generate-all
but I couldn't make it to work (yes, I did adapte it to my setup) : TTY problem then no output log empty.
I there a simple way to fix this memory problem ?
@kjlhgfds Before I made the Docker image I was adding the memory limit to the nextcloud .htaccess file. That was the only way that worked for me. You have to make the change every time you redeploy the image so I did it with Ansible.
I already have
php_value memory_limit 512M
under both
<IfModule mod_php5.c>
and
<IfModule mod_php7.c>
Did you add anything else ?
@kjlhgfds I looked at my Ansible tasks to see how I did it. I did a regex and updated the current value already in the .htaccess in the /html directory and replaced 512M with 2G.
@FriedCircuits I don't have a /html directory.
I have a .htaccess in the /www directory, in wich I changed both php_value memory_limit from 512M to 2G.
Still have the same problem : /
Here is my .htaccess :
<IfModule mod_headers.c>
<IfModule mod_setenvif.c>
<IfModule mod_fcgid.c>
SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
</IfModule>
<IfModule mod_proxy_fcgi.c>
SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
</IfModule>
<IfModule mod_env.c>
# Add security and privacy related headers
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
Header set X-Robots-Tag "none"
Header set X-Download-Options "noopen"
Header set X-Permitted-Cross-Domain-Policies "none"
SetEnv modHeadersAvailable true
</IfModule>
# Add cache control for static resources
<FilesMatch "\.(css|js|svg|gif)$">
Header set Cache-Control "max-age=15778463"
</FilesMatch>
# Let browsers cache WOFF files for a week
<FilesMatch "\.woff$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
</IfModule>
<IfModule mod_php5.c>
php_value upload_max_filesize 511M
php_value post_max_size 511M
php_value memory_limit 2G
php_value mbstring.func_overload 0
php_value always_populate_raw_post_data -1
php_value default_charset 'UTF-8'
php_value output_buffering 0
<IfModule mod_env.c>
SetEnv htaccessWorking true
</IfModule>
</IfModule>
<IfModule mod_php7.c>
php_value upload_max_filesize 511M
php_value post_max_size 511M
php_value memory_limit 2G
php_value mbstring.func_overload 0
php_value default_charset 'UTF-8'
php_value output_buffering 0
<IfModule mod_env.c>
SetEnv htaccessWorking true
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} DavClnt
RewriteRule ^$ /remote.php/webdav/ [L,R=302]
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####
ErrorDocument 403 //
ErrorDocument 404 //