No Description

Tilo Spannagel 6c1044fef4 Merge pull request #1020 from tilosp/bot/update 1 year ago
.config d9ab30a969 Fix Redis Unix socket support (#944) 1 year ago
.examples ac8c998431 rename imagick extension package for buster compat (#1008) 1 year ago
.travis b3df4606be remove official images test for example images 3 years ago
16.0 96c5d80121 Run 1 year ago
16.0-rc da5b3bed1f Run 1 year ago
17.0 96c5d80121 Run 1 year ago
17.0-rc da5b3bed1f Run 1 year ago
18.0 884d8c21a5 Run 1 year ago
18.0-rc da5b3bed1f Run 1 year ago
.travis.yml da5b3bed1f Run 1 year ago 31c0ec75df Add code of conduct 3 years ago
Dockerfile-alpine.template 0e24415434 Upgrade Alpine to 3.11 1 year ago
Dockerfile-debian.template 7eb00b62aa Add gmp php extension 2 years ago 5c7ba18637 Add the GNU Affero General Public License 3 years ago d5ecc2149f Readme: improve migration from existing section (#894) 1 year ago 5dbd0b220f Make posix compliant 3 years ago 13be446667 Change sleep time from 3s to 10s in all files (#963) 1 year ago ce4af3ac34 Update production tag 1 year ago
logo.svg 80dd587d84 Update logo.svg 3 years ago
stack.yml 8db861d67f Use for the cron container 3 years ago 8c96d5b7ad Remove end of life version 15.0 1 year ago
upgrade.exclude 9c769f4ffc Copy version.php last 2 years ago

What is Nextcloud?

Build Status Travis amd64 build status badge arm32v5 build status badge arm32v6 build status badge arm32v7 build status badge arm64v8 build status badge i386 build status badge ppc64le build status badge

A safe home for all your data. Access & share your files, calendars, contacts, mail & more from any device, on your terms.


How to use this image

This image is designed to be used in a micro-service environment. There are two versions of the image you can choose from.

The apache tag contains a full Nextcloud installation including an apache web server. It is designed to be easy to use and gets you running pretty fast. This is also the default for the latest tag and version tags that are not further specified.

The second option is a fpm container. It is based on the php-fpm image and runs a fastCGI-Process that serves your Nextcloud page. To use this image it must be combined with any webserver that can proxy the http requests to the FastCGI-port of the container.

Try in PWD

Using the apache image

The apache image contains a webserver and exposes port 80. To start the container type:

$ docker run -d -p 8080:80 nextcloud

Now you can access Nextcloud at http://localhost:8080/ from your host system.

Using the fpm image

To use the fpm image, you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases, you might want use another container or your host as proxy. If you use your host you can address your Nextcloud container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via docker run --network <NAME> ... or a docker-compose file). In both cases you don't want to map the fpm port to your host.

$ docker run -d nextcloud:fpm

As the fastCGI-Process is not capable of serving static files (style sheets, images, ...), the webserver needs access to these files. This can be achieved with the volumes-from option. You can find more information in the docker-compose section.

Using an external database

By default, this container uses SQLite for data storage but the Nextcloud setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. --link my-mysql:mysql, and then use mysql as the database host on setup. More info is in the docker-compose section.

Persistent data

The Nextcloud installation and all data beyond what lives in the database (file uploads, etc) are stored in the unnamed docker volume volume /var/www/html. The docker daemon will store that data within the docker directory /var/lib/docker/volumes/.... That means your data is saved even if the container crashes, is stopped or deleted.

A named Docker volume or a mounted host directory should be used for upgrades and backups. To achieve this, you need one volume for your database container and one for Nextcloud.


  • /var/www/html/ folder where all nextcloud data lives console $ docker run -d \ -v nextcloud:/var/www/html \ nextcloud


  • /var/lib/mysql MySQL / MariaDB Data
  • /var/lib/postgresql/data PostgreSQL Data console $ docker run -d \ -v db:/var/lib/mysql \ mariadb

If you want to get fine grained access to your individual files, you can mount additional volumes for data, config, your theme and custom apps. The data, config files are stored in respective subfolders inside /var/www/html/. The apps are split into core apps (which are shipped with Nextcloud and you don't need to take care of) and a custom_apps folder. If you use a custom theme it would go into the themes subfolder.

Overview of the folders that can be mounted as volumes:

  • /var/www/html Main folder, needed for updating
  • /var/www/html/custom_apps installed / modified apps
  • /var/www/html/config local configuration
  • /var/www/html/data the actual data of your Nextcloud
  • /var/www/html/themes/<YOUR_CUSTOM_THEME> theming/branding

If you want to use named volumes for all of these, it would look like this:

$ docker run -d \
-v nextcloud:/var/www/html \
-v apps:/var/www/html/custom_apps \
-v config:/var/www/html/config \
-v data:/var/www/html/data \
-v theme:/var/www/html/themes/<YOUR_CUSTOM_THEME> \

Using the Nextcloud command-line interface

To use the Nextcloud command-line interface (aka. occ command):

$ docker exec --user www-data CONTAINER_ID php occ

or for docker-compose:

$ docker-compose exec --user www-data app php occ

Auto configuration via environment variables

The nextcloud image supports auto configuration via environment variables. You can preconfigure everything that is asked on the install page on first run. To enable auto configuration, set your database connection via the following environment variables. ONLY use one database type!


  • SQLITE_DATABASE Name of the database using sqlite


  • MYSQL_DATABASE Name of the database using mysql / mariadb.
  • MYSQL_USER Username for the database using mysql / mariadb.
  • MYSQL_PASSWORD Password for the database user using mysql / mariadb.
  • MYSQL_HOST Hostname of the database server using mysql / mariadb.


  • POSTGRES_DB Name of the database using postgres.
  • POSTGRES_USER Username for the database using postgres.
  • POSTGRES_PASSWORD Password for the database user using postgres.
  • POSTGRES_HOST Hostname of the database server using postgres.

If you set any values, they will not be asked in the install page on first run. With a complete configuration by using all variables for your database type, you can additionally configure your Nextcloud instance by setting admin user and password (only works if you set both):

  • NEXTCLOUD_ADMIN_USER Name of the Nextcloud admin user.
  • NEXTCLOUD_ADMIN_PASSWORD Password for the Nextcloud admin user.

If you want, you can set the data directory and table prefix, otherwise default values will be used.

  • NEXTCLOUD_DATA_DIR (default: /var/www/html/data) Configures the data directory where nextcloud stores all files from the users.
  • NEXTCLOUD_TABLE_PREFIX (default: "") Optional prefix for the tables. Used to be oc_ in the past

One or more trusted domains can be set through environment variable, too. They will be added to the configuration after install.

  • NEXTCLOUD_TRUSTED_DOMAINS (not set by default) Optional space-separated list of domains

The install and update script is only triggered when a default command is used (apache-foreground or php-fpm). If you use a custom command you have to enable the install / update with

  • NEXTCLOUD_UPDATE (default: 0)

If you want to use Redis you have to create a separate Redis container in your setup / in your docker-compose file. To inform Nextcloud about the Redis container, pass in the following parameters:

  • REDIS_HOST (not set by default) Name of Redis container
  • REDIS_HOST_PORT (default: 6379) Optional port for Redis, only use for external Redis servers that run on non-standard ports.
  • REDIS_HOST_PASSWORD (not set by default) Redis password

The use of Redis is recommended to prevent file locking problems. See the examples for further instructions.

To use an external SMTP server, you have to provide the connection details. To configure Nextcloud to use SMTP add:

  • SMTP_HOST (not set by default): The hostname of the SMTP server.
  • SMTP_SECURE (empty by default): Set to ssl to use SSL, or tls to use STARTTLS.
  • SMTP_PORT (default: 465 for SSL and 25 for non-secure connections): Optional port for the SMTP connection. Use 587 for an alternative port for STARTTLS.
  • SMTP_AUTHTYPE (default: LOGIN): The method used for authentication. Use PLAIN if no authentication is required.
  • SMTP_NAME (empty by default): The username for the authentication.
  • SMTP_PASSWORD (empty by default): The password for the authentication.
  • MAIL_FROM_ADDRESS (not set by default): Use this address for the 'from' field in the emails sent by Nextcloud.
  • MAIL_DOMAIN (not set by default): Set a different domain for the emails than the domain where Nextcloud is installed.

Check the Nextcloud documentation for other values to configure SMTP.

Running this image with docker-compose

The easiest way to get a fully featured and functional setup is using a docker-compose file. There are too many different possibilities to setup your system, so here are only some examples of what you have to look for.

At first, make sure you have chosen the right base image (fpm or apache) and added features you wanted (see below). In every case, you would want to add a database container and docker volumes to get easy access to your persistent data. When you want to have your server reachable from the internet, adding HTTPS-encryption is mandatory! See below for more information.

Base version - apache

This version will use the apache image and add a mariaDB container. The volumes are set to keep your data persistent. This setup provides no ssl encryption and is intended to run behind a proxy.

Make sure to pass in values for MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD variables before you run this setup.

version: '2'


    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
      - db:/var/lib/mysql
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

    image: nextcloud
      - 8080:80
      - db
      - nextcloud:/var/www/html
    restart: always

Then run docker-compose up -d, now you can access Nextcloud at http://localhost:8080/ from your host system.

Base version - FPM

When using the FPM image, you need another container that acts as web server on port 80 and proxies the requests to the Nextcloud container. In this example a simple nginx container is combined with the Nextcloud-fpm image and a MariaDB database container. The data is stored in docker volumes. The nginx container also needs access to static files from your Nextcloud installation. It gets access to all the volumes mounted to Nextcloud via the volumes_from option.The configuration for nginx is stored in the configuration file nginx.conf, that is mounted into the container. An example can be found in the examples section here.

As this setup does not include encryption, it should to be run behind a proxy.

Make sure to pass in values for MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD variables before you run this setup.

version: '2'


    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
      - db:/var/lib/mysql
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

    image: nextcloud:fpm
      - db
      - nextcloud:/var/www/html
    restart: always

    image: nginx
      - 8080:80
      - app
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - app
    restart: always

Then run docker-compose up -d, now you can access Nextcloud at http://localhost:8080/ from your host system.

Make your Nextcloud available from the internet

Until here, your Nextcloud is just available from you docker host. If you want your Nextcloud available from the internet adding SSL encryption is mandatory.

HTTPS - SSL encryption

There are many different possibilities to introduce encryption depending on your setup.

We recommend using a reverse proxy in front of our Nextcloud installation. Your Nextcloud will only be reachable through the proxy, which encrypts all traffic to the clients. You can mount your manually generated certificates to the proxy or use a fully automated solution which generates and renews the certificates for you.

In our examples section we have an example for a fully automated setup using a reverse proxy, a container for Let's Encrypt certificate handling, database and Nextcloud. It uses the popular nginx-proxy and docker-letsencrypt-nginx-proxy-companion containers. Please check the according documentations before using this setup.

First use

When you first access your Nextcloud, the setup wizard will appear and ask you to choose an administrator account username, password and the database connection. For the database use db as host and nextcloud as table and user name. Also enter the password you chose in your docker-compose.yml file.

Update to a newer version

Updating the Nextcloud container is done by pulling the new image, throwing away the old container and starting the new one.

It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16.

Since all data is stored in volumes, nothing gets lost. The startup script will check for the version in your volume and the installed docker version. If it finds a mismatch, it automatically starts the upgrade process. Don't forget to add all the volumes to your new container, so it works as expected.

$ docker pull nextcloud
$ docker stop <your_nextcloud_container>
$ docker rm <your_nextcloud_container>
$ docker run <OPTIONS> -d nextcloud

Beware that you have to run the same command with the options that you used to initially start your Nextcloud. That includes volumes, port mapping.

When using docker-compose your compose file takes care of your configuration, so you just have to run:

$ docker-compose pull
$ docker-compose up -d

Adding Features

A lot of people want to use additional functionality inside their Nextcloud installation. If the image does not include the packages you need, you can easily build your own image on top of it. Start your derived image with the FROM statement and add whatever you like.

FROM nextcloud:apache

RUN ...

The examples folder gives a few examples on how to add certain functionalities, like including the cron job, smb-support or imap-authentication.

If you use your own Dockerfile, you need to configure your docker-compose file accordingly. Switch out the image option with build. You have to specify the path to your Dockerfile. (in the example it's in the same directory next to the docker-compose file)

    build: .
      - db
      - data:/var/www/html/data
      - config:/var/www/html/config
      - apps:/var/www/html/apps
    restart: always

If you intend to use another command to run the image, make sure that you set NEXTCLOUD_UPDATE=1 in your Dockerfile. Otherwise the installation and update will not work.

FROM nextcloud:apache



CMD ["/usr/bin/supervisord"]

Updating your own derived image is also very simple. When a new version of the Nextcloud image is available run:

docker build -t your-name --pull .
docker run -d your-name

or for docker-compose:

docker-compose build --pull
docker-compose up -d

The --pull option tells docker to look for new versions of the base image. Then the build instructions inside your Dockerfile are run on top of the new image.

Migrating an existing installation

You're already using Nextcloud and want to switch to docker? Great! Here are some things to look out for:

  1. Define your whole Nextcloud infrastructure in a docker-compose file and run it with docker-compose up -d to get the base installation, volumes and database. Work from there.
  2. Restore your database from a mysqldump (nextcloud_db_1 is the name of your db container)
    • To import from a MySQL dump use the following commands console docker cp ./database.dmp nextcloud_db_1:/dmp docker-compose exec db sh -c "mysql -u USER -pPASSWORD nextcloud < /dmp" docker-compose exec db rm /dmp
    • To import from a PostgreSQL dump use to following commands console docker cp ./database.dmp nextcloud_db_1:/dmp docker-compose exec db sh -c "psql -U USER --set ON_ERROR_STOP=on nextcloud < /dmp" docker-compose exec db rm /dmp
  3. Edit your config.php

    1. Set database connection
      • In case of MySQL database php 'dbhost' => 'db:3306',
      • In case of PostgreSQL database php 'dbhost' => 'db:5432',
    2. Make sure you have no configuration for the apps_paths. Delete lines like these ```diff
    3. "apps_paths" => array (
    4. 0 => array (
    5. "path" => OC::$SERVERROOT."/apps",
    6. "url" => "/apps",
    7. "writable" => true,
    8. ), ```
    9. Make sure to have the apps directory non writable and the custom_apps directory writable php 'apps_paths' => array ( 0 => array ( 'path' => '/var/www/html/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/www/html/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ),
    10. Make sure your data directory is set to /var/www/html/data php 'datadirectory' => '/var/www/html/data',
  4. Copy your data (nextcloud_app_1 is the name of your Nextcloud container):

    docker cp ./data/ nextcloud_app_1:/var/www/html/
    docker-compose exec app chown -R www-data:www-data /var/www/html/data
    docker cp ./theming/ nextcloud_app_1:/var/www/html/
    docker-compose exec app chown -R www-data:www-data /var/www/html/theming
    docker cp ./config/config.php nextcloud_app_1:/var/www/html/config
    docker-compose exec app chown -R www-data:www-data /var/www/html/config
  5. Copy only the custom apps you use (or simply redownload them from the web interface):

    docker cp ./custom_apps/ nextcloud_data:/var/www/html/
    docker-compose exec app chown -R www-data:www-data /var/www/html/custom_apps

Questions / Issues

If you got any questions or problems using the image, please visit our Github Repository and write an issue.