Docker external storage with the Raspberry Pi

Hi,
i m using the latest Nextcloudpi Docker image on my raspberry pi 3. I want to store my data on my external usb storage. The nc-init throws the following message:

Console has to be executed with the user that owns the file config/config.php
Current user: www-data
Owner of config.php: root
Try adding 'sudo -u root ’ to the beginning of the command (without the single quotes)

If i change the volume to the local sd card eg. ‘/home/pi/nextcloudpi-test/’ the installation was successful.

How can i external the docker volume?

Mount

sudo mount -o rw /dev/sda1 /media/usb

Docker Run:

docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /media/usb/Docker/nextcloudpi:/data --name nextcloudpi-test ownyourbits/nextcloudpi-armhf 192.168.178.38

Logs:

docker logs -f nextcloudpi-test
Initializing empty volume…
Making /usr/local/etc/ncp-config.d persistent …
Making /etc/services-enabled.d persistent …
Making /etc/letsencrypt persistent …
Making /etc/shadow persistent …
Making /etc/cron.d persistent …
Making /etc/cron.daily persistent …
Making /etc/cron.hourly persistent …
Making /etc/cron.weekly persistent …
Making /usr/local/bin persistent …
Making /etc/apache2 persistent …
Starting PHP-fpm
Starting Apache
Starting mariaDB
2019-01-30 21:33:05 1996365824 [Note] mysqld (mysqld 10.1.37-MariaDB-0+deb9u1) starting as process 87 …
Starting Redis
Starting Cron
Starting Postfix
Uninitialized instance, running nc-init…
Running nc-init
Setting up a clean Nextcloud instance… wait until message ‘NC init done’
Setting up database…
Setting up Nextcloud…
Console has to be executed with the user that owns the file config/config.php
Current user: www-data
Owner of config.php: root
Try adding 'sudo -u root ’ to the beginning of the command (without the single quotes)
Init done

Thank you very much
`

Do you have automount enabled? It will take care of mounting for you.
What do you mean by: external the docker volume?

Try:

sudo usermod -aG docker pi

This will add pi to the docker group and allow docker commands without using sudo (Replace pi by username running the docker.)

Or prepend sudo to run/start/manage docker.

I mean that I want to store the config for the Docker Image in the USB Storage. (‘Data Folder’). So i can restart the container every time with the same config.

I think i have add the user to the docker group, but I will check it later.

Thank you!

You can store data persistently by using the -v option to mount any volume you want. Wiki example here.

Yes i allreday used the -v option to the usb storage. I have added the usermod. But there is the same Message.
Can i restart the init or is it possible to assign the rights for the user www-data

Docker run

docker run -d -p 4444:4443 -p 444:443 -p 81:80 -v /media/ncdata/nextcloudpi:/data --name nextcloudpi-test ownyourbits/nextcloudpi-armhf 192.168.178.38

Setting up Nextcloud…
Console has to be executed with the user that owns the file config/config.php
Current user: www-data
Owner of config.php: root
Try adding 'sudo -u root ’ to the beginning of the command (without the single quotes)
Init done