I’m running the official owncloud image. This is basically a PHP application running under Apache that lives in /var/www/html. It writes (potentially quite a lot of) data to /var/www/html/data. It runs as the user www-data (UID 33).
I’m running Docker 1.9.1 on OSX using docker-machine. Everything should be completely up to date.
I want to mount a directory from my NAS onto /var/www/html/data so that the data is stored on my NAS and not locally. I’ve done this with a mount in docker-compose.
There are two problems with this:
With docker-machine on OSX, anything outside /Users isn’t mountable by default (or rather, the mount comes from the VM, not OSX). I tried to work around this by symlinking /Volumes/backup/owncloud (the intended target) to ~/docker/owncloud and mounting this.
I get a Permission Denied error in owncloud because it can’t write to the relevant directory, due to the change in ownership. I also think the symlinking gets in the way of trying to chown the directory to UID 33 (which doesn’t exist on the Mac or the NAS).
I found a solution, somewhat hacky but understandable.
This dance is kind of tricky. We ultimately want to map a folder on the NAS
as seen by the Mac, to the data directory in the owncloud container. As an
added complication, this folder has to be seen by the container as being owned
by uid 33, because that’s what Apache happens to be running as.
The general approach is to mount the NAS drive on /Volumes/backup on the Mac,
configure a shared folder in VirtualBox so that VirtualBox sees this, but mount
it in VirtualBox in such a way that all files are owned by uid 33, and then use
this as the volume mount in Docoker.
Mount /Volumes/backup from NAS in OSX
Create folders on the NAS, writeable as user under which VirtualBox is running: