Tuesday, 20 October 2015

OwnCloud in Docker.

So today version 8.2 of OwnCloud is released (https://owncloud.org/blog/owncloud-server-8-2-comes-tomorrow-help-spread-the-word/). In this blog post we'll look at how you can deploy OwnCloud in Docker with persistent storage.

There really isn't an alternative quite like OwnCloud either. Think Dropbox, but on your infrastructure, think Google-like features without the data-mining.

So for this image we're going to use JChaney's build https://github.com/jchaney/owncloud

You're as usual going to need Docker installed, just head over to https://docker.com and you'll find an installation guide. In this particular example you're also going to need git installed too. We're going to clone jchaney's repository and build our images.

$ git clone https://github.com/jchaney/owncloud.git 
$ cd owncloud
Then we're going to edit the Dockerfile and change the OWNCLOUD_VERSION from 8.1.3 to 8.2.0
then we just build the owncloud image.  As usual, red indicates things you need to alter for specifically. The naming convention for images is username/imagename.

$ docker build -t alba13/owncloud820 .

I'd suggest altering the Makefile and changing the storage location, which is pointing to /tmp/owncloud (you'll lose your storage when you reboot if you leave it here) to a more useful location (maybe, /srv/docker/owncloud/) and also alter “image_owncloud ?= jchaney/owncloud” to “image_owncloud ?= alba13/owncloud820

$ make owncloud-https

The above command links to the self-signed certs on your host system, however you can edit the Makefile to point to specifically generated certs too. If you want to generate some simple self-signed certs this is a pretty simple guide http://www.akadia.com/services/ssh_test_certificate.html just remember to edit the Makefile and change /etc/ssl/certs/ssl-cert-snakeoil.pem and /etc/ssl/private/ssl-cert-snakeoil.key to names and locations of your certs.

Now the above command(s) will give you a simple OwnCloud deployment that uses SQLite3 for its DB. For most cases that maybe all you're looking for, but JChaney's image also gives you the ability to set up a MariaDB with persistent storage, and uses the --link option. Which basically means that the MariaDB is only accessible to Docker containers that you specifically link to. Don't think of it as a security control though, just think of it as keeping it all in the Docker family.

You can set this up with the following commands;

$ make owncloud-production
# and to find the DB's details to configure OwnCloud run this;
$ make owncloud-mariadb-get-pw
Then just visit and follow OwnCloud's install options.

Once you're set up and installed you can head over to the "Apps" section and add some more functionality to your OwnCloud install. There is an "Enable experimental apps" section, the name sort of suggests you should have a bit of caution.

So here you go, you're up and running with the latest OwnCloud, all wrapped up in a nice little Docker Container(s).


finux Xx

[note] In your make file you can edit the DOCKER_RUN_OPTIONS ?= --restart=always --env "TZ=Europe/Berlin" and change your Timezone. Also as you see above i've added the –restart=always option. This just means that the images will restart after a reboot or if they crash.

[note2] also, just in case you have any sync issues it might be worth adding "fastcgi_read_timeout 120;" to the nginx.conf file(s) with the other fastcgi perimeters.   (https://www.tekovic.com/fixing-timeout-between-nginx-and-php-fpm)