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.
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.
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.
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:
-v /mnt/storage:/mnt/storage
maps /mnt/storage/
on the host to /mnt/storage/
inside the ownCloud image; assumingly /mnt/storage
is a mount point containing files that will then be used within ownCloud as a local filesystem mount,OWNCLOUD_TRUSTED_DOMAINS
is an environment variable that makes localhost
and 127.0.0.1
the domain or IPs from which ownCloud should accept connections from,OWNCLOUD_SUB_URL
maps the base-URL to /cloud
instead of being the default top level path /
, which is useful for reverse-proxying with caddy,-p 8181:8080
maps the local port 8181
to the 8080
port inside the docker image where 8181
is the port that caddy connects to
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:
owncloud
is the name of the docker container
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