Hello,
I’m experimenting with Nextcloud and I’m fairly new
I’m using the latest official Nextcloud docker image.
As I understand it, when I build the image and run the container, additional setup is required by going on the web interface and creating the admin account and enabling certain apps.
In my case, I would like to build the image non-interactively and I’ve learned that the php occ feature is how I can do this, except when I include these commands in my Dockerfile and build the image, I get the error Could not open input file: /var/www/html/occ
.
When I build just the base image without the occ commands and docker exec into the container the command works just fine. I suppose there’s something conflicting in the backend which doesn’t allow me to run occ before the container is built.
I’d like to know if there’s a way around this where I can have the Nextcloud image with the admin and external storage already set up without intervention.
My Dockerfile looks like this:
FROM nextcloud:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y libz-dev libpcre3-dev sudo
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
RUN composer require aws/aws-sdk-php
RUN chmod 755 -R /var/www
# Testing the occ command
RUN sudo -u www-data php /var/www/html/occ list
CMD ["apache2-foreground"]
The result of docker build:
#17 [13/13] RUN sudo -u www-data php /var/www/html/occ list
#17 sha256:fa3ccf0b42bb63c1dacb6e476ccb30395de21fc84ccb23eaed8eb77e6dd3f2dc
#17 0.378
#17 0.378 Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
#17 0.378 Could not open input file: /var/www/html/occ
#17 ERROR: executor failed running [/bin/sh -c sudo -u www-data php /var/www/html/occ list]: exit code: 1
Please let me know if I can provide more details, thanks!