The Nextcloud Docker images from hub.docker.com, either the official or the 3rd-party like linuxserver.io, use php with default configurations, which is not optimized to run a complicated and resource consuming application like Nextcloud in a production environment.
I integrated the recommended configurations from Nextcloud document with php:fpm-alpine as base image.
Please be aware, after build, the image has only php-fpm runtime environment, has no Nextcloud source code built-in. You have to download Nextcloud server package and extract into the mapped folder. See the below usage section.
$ git clone https://github.com/fishingsun/phpfpm-nextcloud-docker.git
$ cd phpfpm-nextcloud-docker
$ docker build -t php:7.4fpm-nc .- If your local docker environment has no default bridge network, please add
--networkoption; - If you plan to upload the image into your docker hub repo, recommend to add your hub id and hub repo name in tag;
- for example:
$ docker build --network ipvlan -t hyscom/phpfpm:7.4-nextcloud .After compiled successfully, the new image should be listed:
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hyscom/phpfpm 7.4-nextcloud 97e8492c353d 5 minutes ago 267MB
php fpm-alpine f2a53c8e8392 2 days ago 71.4MBCreate the working folder:
$ sudo mkdir -p /srv/phpfpm-apps/nextcloud-dataDownload nextcloud server package, and extract to /srv/phpfpm-apps:
$ wget https://download.nextcloud.com/server/releases/nextcloud-18.0.3.tar.bz2
$ sudo tar jxf nextcloud-18.0.3.tar.bz2 -C /srv/phpfpm-appsChange the folders ownership:
$ sudo chown -R www-data:www-data /srv/phpfpm-appsPlease make sure the host has user www-data and group www-data, and their UID and GID are 33.
Run container:
$ docker run --name phpfpm --restart unless-stopped \
--network ipvlan --ip=192.168.0.204 -v /srv/phpfpm-apps:/var/www/html \
-d hyscom/phpfpm:7.4-nextcloudOf course, you need a reverse proxy, pointing to 192.168.0.204:9000 in the above example case. Recommend Caddy or Nginx.
Recommend to use an independent database server to replace the built-in SQLite due to performance concern, for example, MariaDB.