Installing with Docker

Introduction

ownCloud can be installed using the official ownCloud Docker image. This official image is designed to be used in a docker compose setup but can also be used for a quick evaluation.

Starting with ownCloud Server 11, the only supported installation method is a Docker-based installation which includes PHP 8 and Apache. Manual installation on Linux is no longer supported.

Database Notes

With the image provided, ownCloud has added database connectors for the following databases:

  • MySQL / MariaDB

  • Postgres

  • SQLite

If you need a different connector or a different version of a connector, you have to manually create your own image based on the ownCloud image provided here. This could also be done directly in the docker compose file.

Getting Started

Grant docker command privileges to certain users by adding them to the group docker:

sudo usermod -aG docker <your-user>
The changes via usermod only take effect after the docker users log in. So you may have to log out and log in again or possibly reboot before you can run docker commands.

Users not added to the docker group can run docker commands with a preceding sudo. In this section sudo is generally omitted before docker commands since we assume you have created a docker user, which is also the only way to run ownCloud’s command-line interface occ in a docker container. For more information on occ, see section Using the occ Command.

An example occ command looks like this:

docker compose exec owncloud occ <your-command>

Quick Evaluation

The commands and links provided in the following descriptions are intended to showcase basic docker usage, but we cannot take responsibility for their proper functioning.

For testing purposes or a quick hands-on to get familiar with the look and feel, ownCloud provides a container using the SQLite database. Note that SQLite is not supported by ownCloud for production purposes. To set up such a testing instance, run the following command:

docker run --rm --name oc-eval -d -p8080:8080 owncloud/server

This starts a docker container with the name "oc-eval" in the background (option -d). owncloud/server is the docker image downloaded from Docker Hub. If you don’t start the container with option -d, the logs will be displayed in the shell. If you are running it in the background as in the example above, you can display the logs with the command:

docker logs oc-eval

With the command docker ps you can list your running docker containers and should see the entry for oc-eval.

You can log in to your ownCloud instance via a browser at http://localhost:8080 with the preconfigured user admin and password admin.

Access only works locally with http, not https.

If you want to access the occ CLI command set with the quick evaluation setup, you must use:

docker exec --user www-data oc-eval occ <command>

instead the docker compose exec version as used in the documentation.

If the outcome meets the expectations but a supported installation with MariaDB is targeted, remove the eval version before proceeding with the next section.

docker kill oc-eval

This removes the container if you used the option --rm as suggested in the example above. If you omitted that option, you need to first run the command:

docker rm oc-eval

When running docker ps again, the entry for oc-eval should be gone.

Docker Compose

The example configuration:

  • Exposes ports 8080, allowing for HTTP connections.

  • Uses separate MariaDB and Redis containers.

  • Provides mounts plus a volume bind configuration example.

Compose Setup

The following instructions assume you install locally. For remote access, the value of OWNCLOUD_DOMAIN and OWNCLOUD_TRUSTED_DOMAINS must be updated to represent the hostname(s) and/or IP addresses that the server is reachable at.

  1. Create a new project directory at a location of choice:

    mkdir owncloud-server-docker
    cd owncloud-server-docker
  2. Create a docker-compose.yml file as base to derive from with the following content:

    # This oc-common template is a compose extension for ownCloud.
    # It is used for starting the main ownCloud instance and reused e.g. when defining listeners for WND.
    # This eases compose maintenance a lot.
    x-owncloud: &oc-common
        image: owncloud/server:${OWNCLOUD_IMAGE}
        restart: always
        depends_on:
          - mariadb
          - redis
        environment:
          - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
          - OWNCLOUD_TRUSTED_DOMAINS=${OWNCLOUD_TRUSTED_DOMAINS}
          - OWNCLOUD_OVERWRITE_CLI_URL=${OWNCLOUD_OVERWRITE_CLI_URL}
          - OWNCLOUD_DB_TYPE=mysql
          - OWNCLOUD_DB_NAME=owncloud
          - OWNCLOUD_DB_USERNAME=owncloud
          - OWNCLOUD_DB_PASSWORD=owncloud
          - OWNCLOUD_DB_HOST=mariadb
          - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
          - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
          - OWNCLOUD_MYSQL_UTF8MB4=true
          - OWNCLOUD_REDIS_ENABLED=true
          - OWNCLOUD_REDIS_HOST=redis
        volumes:
          - type: volume
            source: oc_files
            target: /mnt/data
        networks:
          - oc_network
    
    services:
    
      owncloud:
        # Start the main ownCloud instance
        <<: *oc-common
        container_name: owncloud_server
        ports:
          - ${HTTP_PORT}:8080
    
    #  owncloud-wnd-1:
    #    # Enterprise only: uncomment and configure it accordingly if WND is used !
    #    # Create as many of these services (containers) as you need listeners for different host/share pairs.
    #    # Read the documentation for more details, such when you want to use a password file.
    #    <<: *oc-common
    #    container_name: owncloud-wnd-1
    #    command: ["/usr/bin/owncloud", "occ", "wnd:listen", "myhost", "myshare", "workgroup\myuser", "password"]
    
      mariadb:
        image: mariadb:${MARIADB_IMAGE}
        container_name: owncloud_mariadb
        restart: always
        ports:
          - "3306:3306"
        environment:
          - MYSQL_ROOT_PASSWORD=owncloud
          - MYSQL_USER=owncloud
          - MYSQL_PASSWORD=owncloud
          - MYSQL_DATABASE=owncloud
          - MARIADB_AUTO_UPGRADE=1
        command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"]
        healthcheck:
          test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"]
          interval: 10s
          timeout: 5s
          retries: 5
        volumes:
          - mysql:/var/lib/mysql
        networks:
          - oc_network
    
      redis:
        image: redis:${REDIS_IMAGE}
        container_name: owncloud_redis
        restart: always
        ports:
          - "6379:6379"
        command: ["--databases", "1"]
        healthcheck:
          test: ["CMD", "redis-cli", "ping"]
          interval: 10s
          timeout: 5s
          retries: 5
        volumes:
          - redis:/data
        networks:
          - oc_network
    
    volumes:
      oc_files:
        driver: local
    # Options when using bind mounts
    #    driver_opts:
    #      type: none
    #      device: /mnt/oc
    #      o: bind
      mysql:
        driver: local
    # Use the above options when configuring bind mounts
      redis:
        driver: local
    
    networks:
      oc_network:
  3. Create an .env configuration file in the same directory, which contains the required configuration settings.

    OWNCLOUD_IMAGE=10.16.2
    OWNCLOUD_DOMAIN=localhost
    OWNCLOUD_TRUSTED_DOMAINS=localhost
    OWNCLOUD_OVERWRITE_CLI_URL=http://localhost
    HTTP_PORT=8080
    MARIADB_IMAGE=10.11
    REDIS_IMAGE=7

    Only a few settings are required, these are:

    Setting Name Description Example

    OWNCLOUD_IMAGE

    The ownCloud version

    10.16.2 or latest

    OWNCLOUD_DOMAIN 1

    A single ownCloud domain

    Either use:
    OWNCLOUD_DOMAIN
       OR
    OWNCLOUD_TRUSTED_DOMAINS.
    Only use a single domain.
    The same trusted domains rules apply to everything else.

    my_domain or my_ip …​

    Multiple ownCloud Domains.
    See the config description for more details.

    my_host,my_ip,my_domain

    See the config description for more details.

    http://localhost

    ADMIN_USERNAME

    The webUI admin username

    admin

    ADMIN_PASSWORD

    The webUI admin user’s password

    admin

    HTTP_PORT

    The HTTP port to bind to

    8080

    MARIADB_IMAGE

    The mariadb version

    10.11

    REDIS_IMAGE

    The redis version

    7

    • ADMIN_USERNAME and ADMIN_PASSWORD
      will not change between deploys even if you change the values in the .env file.
      To change them, you will need to issue docker volume prune, which will delete all your data.

    • (1) …​ localhost is always included and cannot be removed by omitting it. It must be used if only one entry is to be defined.

    • (2) …​ To access ownCloud from your internal network without using an externally resolvable URL, you must add the IP address of the host or an internal resolvable URL running the container.

  4. Start the container using your preferred Docker command-line tool such as:

    docker compose up -d
  5. When the process completes:

    Check that all the containers have successfully started, by running docker compose ps. If they are all working correctly, you should see output similar to the one below:

    Name Command State Ports

    owncloud_mariadb

    docker-entrypoint.sh --max …​

    Up (healthy)

    3306/tcp

    owncloud_redis

    docker-entrypoint.sh --dat …​

    Up (healthy)

    6379/tcp

    owncloud_server

    /usr/bin/entrypoint /usr/b …​

    Up (healthy)

    0.0.0.0:8080→8080/tcp

    Here you can see, that the database, ownCloud and Redis containers are running, and that ownCloud is accessible via port 8080 on the host machine.

    Although the containers are up and running, it may still take a few minutes until ownCloud is fully functional.
    To inspect the log output:

    docker compose logs --follow owncloud

    Wait until the output shows Starting apache daemon…​ before you access the web UI.

    All files stored in this setup are contained in Docker volumes rather than a physical filesystem tree. It is the admin’s responsibility to make the files persistent. For details how to migrate, see the docker container cp command documentation.
    Any apps that came with the image will reappear when the container is restarted - if you uninstall them.

Logging In

To log in to the ownCloud UI, open http://localhost:8080 (or the URL defined) in your browser of choice, where you see the standard ownCloud login screen as in the image below.

The ownCloud UI via Docker
The username and password are the credentials which you stored in .env earlier. These will not change between deploys even if you change the values in the .env file.

Stopping the Containers

To stop the containers, issue the following command:

docker compose stop

To stop and remove containers along with the related networks, images and volumes:

docker compose down --rmi all --volumes --remove-orphans

Running occ commands

If you want to run an occ command, first go to the directory where your compose .yaml file is located. Here, you are able to run any command referring to Using the occ Command by entering:

docker compose exec owncloud occ <command>
Don’t use the php command prefix, this leads to several errors and is not intended to run in docker environments.

Configuration

For more configuration options, please refer to the Configuration Notes documentation.

Enterprise License Keys

An Enterprise license keys can be added by:

  • Using an environment variable named OWNCLOUD_LICENSE_KEY, or

  • By adding a config entry.
    For more details see the Configuration Notes documentation.

  • It is also possible to activate your Enterprise Edition on the webUI.
    Open owncloud and navigate to: Settings  Admin  General. Copy your license key into the field Enter a new license: and click Save to confirm.

Introduction

You need to install a license key to use ownCloud Enterprise Edition. There are two types of license keys:

  • One is a free 30-day trial key.

  • The other is a full license key for Enterprise customers.

You can download and try ownCloud Enterprise for 30 days for free, which auto-generates a free 30-day key. When this key expires, your ownCloud installation is not removed, only enterprise features are disabled. If you become an Enterprise customer, you can enter your new key to regain access. See How to Buy ownCloud for sales and contact information.

Configuration

Once you get your Enterprise license key, it needs to be copied to your ownCloud configuration file config/config.php like in this example:

'license-key' => 'test-20150101-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-YYYYYY',

Each running instance of ownCloud requires a license key. Keys will work across upgrades without issue, so new keys will not be required when you upgrade your ownCloud Enterprise to a new version.

If you want to remove the current license, open ownCloud and navigate to Settings  Admin  General and click Remove current license key.

User Counting

Your ownCloud Enterprise License Key is valid for the purchased amount of users, as per the ownCloud EULA - ownCloud Commercial License. When you generate a config.report, you will get:

  • a counting of the enabled users,

  • the ownCloud guest users — if the guest app is enabled and

  • the number of user directories created.

The latter is the user number you will need licenses for. Guest users are currently counted with a fair use policy — which means, that you can’t have more guest users than you have licensed users. If you exceed the number of licensed users, please contact your account manager or ownCloud Partner and true-up as per your contract or EULA with us. The user directories are created on first login. When a user is deleted, the user directories are deleted as well. Users which are disabled count. The last login is not relevant.

Troubleshooting

Admin Settings

With Docker, the admin user cannot control certain settings in the WebUI, instead they are/can be now controlled by environment variables. Changing these variables requires stopping and restarting the container. When using environment variables, these changes need to be reflected in the compose file.

Logging and Apache2 Config

See the General Troubleshooting guide for:

Container CLI

If you need to access the ownCloud containers CLI for any reason, you can do so using the following command:

docker exec -it owncloud_server /bin/bash

List Shipped Apps

The Docker image comes with all apps provided by ownCloud, regardless of the licensing scheme. To see a list of the apps that have been shipped, you can either look:

  • In the GUI via Settings  Admin  Apps

  • See the Supported Apps in ownCloud page which provides you additional documentation links

  • List the contents of /var/www/owncloud/apps when accessing the container CLI.

Terminating Containers

If your container is terminating for whatever reason, you will not be able to run docker(-compose) exec to make investigations inside the container as there will be no running container. Instead you need to use docker(-compose) run. It’s important that you prefix any command to be run by /usr/bin/owncloud, otherwise the container will not be initialized correctly. See the example command below:

docker( compose) run <containername> /usr/bin/owncloud bash

MySQL

If your ownCloud installation fails and you see the following error in your ownCloud log please refer to MySQL / MariaDB with Binary Logging Enabled for how to resolve it.

An unhandled exception has been thrown: exception ‘PDOException’ with message 'SQLSTATE[HY000]: General error: 1665 Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.'

Upgrading ownCloud

When a new version of ownCloud gets released, you should update your instance. To do so, read the documents located in the Upgrading section.