/docker-nextcloud

🐳 Nextcloud Docker image based on Alpine Linux and Nginx with advanced features

Primary LanguageShellMIT LicenseMIT

Version Build Status Docker Stars Docker Pulls Docker Repository on Quay Code Quality Donate Paypal

About

🐳 Nextcloud Docker image based on Alpine Linux and Nginx with advanced features.
If you are interested, check out my other 🐳 Docker images!

Features

Included

  • Alpine Linux 3.9, Nginx, PHP 7.2
  • Tarball authenticity checked during building process
  • Data, config, user apps and themes persistence in the same folder
  • Automatic installation
  • Cron task for Nextcloud background jobs as a "sidecar" container
  • OPCache enabled to store precompiled script bytecode in shared memory
  • APCu installed and configured
  • Memcached and Redis also enabled to enhance server performance
  • Database connectors MySQL/MariaDB, PostgreSQL and SQLite3 enabled
  • Exif, IMAP, LDAP, FTP, GMP, SMB enabled (required for specific apps)
  • FFmpeg, iconv, Imagick installed for preview generation

From docker-compose

Docker

Environment variables

  • TZ : The timezone assigned to the container (default UTC)
  • MEMORY_LIMIT : PHP memory limit (default 512M)
  • UPLOAD_MAX_SIZE : Upload max size (default 512M)
  • OPCACHE_MEM_SIZE : PHP OpCache memory consumption (default 128)
  • APC_SHM_SIZE : APCu memory size (default 128M)
  • HSTS_HEADER : HTTP Strict Transport Security header value (default max-age=15768000; includeSubDomains)
  • RP_HEADER : Referrer Policy header value (default strict-origin)
  • SUBDIR : Subdir to use. Read this section for more info.
  • DB_TYPE : Database type (mysql, pgsql or sqlite) (default sqlite)
  • DB_NAME : Database name (default nextcloud)
  • DB_USER : Username for database (default nextcloud)
  • DB_PASSWORD : Password for database user (default asupersecretpassword)
  • DB_HOST : Database host (default db)

The following environment variables are used only if you run the container as "sidecar" mode :

  • CRON_PERIOD : Periodically execute Nextcloud cron (disabled if empty ; ex */15 * * * *)

Volumes

  • /data : Contains config, data folders, installed user apps (not core ones), session, themes, tmp folders

Ports

  • 8000 : HTTP port

Use this image

Docker Compose

Docker compose is the recommended way to run this image. Copy the content of folder examples/compose in /var/nextcloud/ on your host for example. Edit the compose and env files with your preferences and run the following commands :

touch acme.json
chmod 600 acme.json
docker-compose up -d
docker-compose logs -f

Command line

You can also use the following minimal command :

docker run -d -p 8000:8000 --name nextcloud \
  -v $(pwd)/data:/data \
  crazymax/nextcloud:latest

Notes

First installation

If you run the container for the first time, the installation will be automatic using the DB_* environment variables.
Then open your browser to configure your admin account.

OCC command

If you want to use the occ command to perform common server operations like manage users, encryption, passwords, LDAP setting, and more, type :

docker-compose exec nextcloud occ

Cron

If you want to enable the cron job, you have to run a "sidecar" container like in the docker-compose file or run a simple container like this :

docker run -d --name nextcloud_cron \
  --env-file $(pwd)/nextcloud.env \
  -e CRON_PERIOD=*/15 * * * * \
  -v $(pwd)/data:/data \
  crazymax/nextcloud:latest /usr/local/bin/cron

Then do not forget to choose Cron as background jobs :

Background jobs

Email

Do not forget to configure your Email server settings with your preferences :

Email server

Redis cache

Redis is recommended, alongside APCu to make Nextcloud more faster. If you want to enable Redis, deploy a redis container (see docker-compose file) and add this to your config.php :

    'memcache.local' => '\OC\Memcache\APCu',
    'memcache.distributed' => '\OC\Memcache\Redis',
    'memcache.locking' => '\OC\Memcache\Redis',
    'redis' => array(
        'host' => 'redis',
        'port' => 6379,
    ),

Running in a subdir

If you want to access your Nextcloud installation in a subdir (like /nextcloud), you have to set the SUBDIR environment variable and also add PathPrefixStrip:/nextcloud to your frontend rule if you use Traefik. Do not forget to remove includeSubDomains option in HSTS_HEADER if used.

Upgrade

To upgrade to the latest version of Nextcloud, pull the newer image and launch the container. Nextcloud will upgrade automatically :

docker-compose pull
docker-compose up -d

How can I help ?

All kinds of contributions are welcome 🙌!
The most basic way to show your support is to star 🌟 the project, or to raise issues 💬
But we're not gonna lie to each other, I'd rather you buy me a beer or two 🍻!

Paypal

License

MIT. See LICENSE for more details.