crazy-max / docker-nextcloud

Nextcloud Docker image
MIT License
239 stars 47 forks source link
alpine-linux cron docker docker-compose letsencrypt mariadb nextcloud nginx redis ssmtp traefik

Latest Version Build Status Docker Stars Docker Pulls
Become a sponsor Donate Paypal

About

Nextcloud Docker image with advanced features.

[!TIP] Want to be notified of new releases? Check out 🔔 Diun (Docker Image Update Notifier) project!


Features

Build locally

git clone https://github.com/crazy-max/docker-nextcloud.git
cd docker-nextcloud

# Build image and output to docker (default)
docker buildx bake

# Build multi-platform image
docker buildx bake image-all

Image

Registry Image
Docker Hub crazymax/nextcloud
GitHub Container Registry ghcr.io/crazy-max/nextcloud

Following platforms for this image are available:

$ docker run --rm mplatform/mquery crazymax/nextcloud:latest
Image: crazymax/nextcloud:latest
 * Manifest List: Yes
 * Supported platforms:
   - linux/amd64
   - linux/arm/v6
   - linux/arm/v7
   - linux/arm64
   - linux/ppc64le
   - linux/s390x

Environment variables

General

Nextcloud

[!NOTE] DB_PASSWORD_FILE can be used to fill in the value from a file, especially for Docker's secrets feature.

Cron

[!WARNING] Only used if you enable and run a sidecar cron container

Previews generator

[!WARNING] Only used if you enable and run a sidecar previews generator container

News Updater

[!WARNING] Only used if you enable and run a sidecar news updater container

Volumes

[!WARNING] Note that the volume should be owned by the user/group with the specified PUID and PGID. If you don't give the volume correct permissions, the container may not start.

Ports

Usage

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:

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

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

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 sidecar

If you want to enable the cronjob, you have to run a "sidecar" container (see cron service in compose.yml example) or run a simple container like this:

docker run -d --name nextcloud_cron \
  --env-file $(pwd)/nextcloud.env \
  -e "SIDECAR_CRON=1" \
  -e "CRON_PERIOD=*/5 * * * *" \
  -v "$(pwd)/data:/data" \
  crazymax/nextcloud:latest

And do not forget to choose Cron as background jobs:

Background jobs

Previews generator sidecar

To execute pre-generation of previews through the Preview Generator plugin, you have to run a "sidecar" container (see cron service in compose.yml example) or run a simple container like this:

docker run -d --name nextcloud_previewgen \
  --env-file $(pwd)/nextcloud.env \
  -e "SIDECAR_PREVIEWGEN=1" \
  -e "PREVIEWGEN_PERIOD=0 * * * *" \
  -v "$(pwd)/data:/data" \
  crazymax/nextcloud:latest

Nextcloud News Updater

If you want to enable the Nextcloud News Updater, you have to run a "sidecar" container (see news_updater service in compose.yml example) or run a simple container like this:

docker run -d --name nextcloud_news_updater \
  --env-file $(pwd)/nextcloud.env \
  -e "SIDECAR_NEWSUPDATER=1" \
  -e "NC_NEWSUPDATER_THREADS=10" \
  -e "NC_NEWSUPDATER_TIMEOUT=300" \
  -e "NC_NEWSUPDATER_INTERVAL=900" \
  -e "NC_NEWSUPDATER_LOGLEVEL=error" \
  -v "$(pwd)/data:/data" \
  crazymax/nextcloud:latest

And do not forget to disable Use system cron for updates in news settings:

Background jobs

Email server

You can use our SMTP relay msmtpd service published on port 2500 and declared in our compose.yml:

Email server config

Redis cache

Redis is recommended, alongside APCu to make Nextcloud faster. If you want to enable Redis, deploy a redis container (see 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.

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by becoming a sponsor on GitHub or by making a PayPal donation to ensure this journey continues indefinitely!

Thanks again for your support, it is much appreciated! :pray:

License

MIT. See LICENSE for more details.