Table of Contents

Running the Official Docker Image

The official ownCloud docker image is a compact image based on SQLite that is self-contained and can be deployed easily. Unfortunately, due to a long track record and many versions, the documentation is somewhat imprecise on various issues such that setting up the docker container can be confusing.

Topology

The topology used in this example is the following:

where caddy will be placed in front of the ownCloud image in order to reverse-proxy all requests as well as providing HTTPs termination.

Caddy (v2)

The caddy v2 configuration used is the following:

:80 {
       redir /cloud /cloud/login
       handle_path /cloud/* {
                rewrite * /cloud{uri}
                reverse_proxy 127.0.0.1:8181 {
                        header_up Host {host}
                        header_up X-Real-IP {remote}
                        header_up X-Forwarded-Proto {scheme}
                }
        }
}

and it is created in order to reverse-proxy ownCloud as a sub URL instead of its own domain.

Docker

The docker image is first pulled using:

docker pull owncloud/server

and then a container is created using the following parameters:

docker run \
    --restart always \
    --name owncloud \
    -v /mnt/storage:/mnt/storage \
    -e OWNCLOUD_TRUSTED_DOMAINS=localhost,127.0.0.1 \
    -e OWNCLOUD_SUB_URL=/cloud \
    -d \
    -p 8181:8080
    owncloud/server

where:

Note that one infamous problem with ownCloud is that ownCloud only accepts connections from the hosts or IP addresses listed in the trusted_domains array within the config/config.php file. However, even if the user starts a shell within the docker container and edits config/config.php, the changes will have no effect such that the OWNCLOUD_TRUSTED_DOMAINS environment variable should be used at startup.

The next annoyance that has to be tackled is that ownCloud does not allow a local folder to be used as external storage and annoyingly enough the only way to enable a local folder as external storage is to edit config/config.php within the container. To that end, the following command can be used to open a shell within the container:

docker exec -u 0 -it owncloud /bin/bash

where:

and then used to inspect or edit config/config.php within the docker container.

Another way is to retrieve a copy of the configuration file:

docker cp owncloud:/var/www/owncloud/config/config.php ./

change it outside the container to include the files_external_allow_create_new_local parameter that will allow mounting local filesystems within the container:

'files_external_allow_create_new_local' => 'true',

and then replace the old configuration file within the container:

docker cp config.php owncloud:/var/www/owncloud/config/config.php