I’m new to Docker.
I’ve tried many different instructions including:
RUN sudo -u www-data /var/www/html/occ etc...
RUN ["sudo -u www-data /var/www/html/occ", "etc..."]
RUN /var/www/html/occ etc...
All of these result in a similar message that
/var/www/html/occ can’t be found (regardless of user):
ERROR: Service ‘core’ failed to build: OCI runtime create failed: container_linux.go:349: starting container process caused “exec: “sudo -u www-data /var/www/html/occ maintenance:install”: stat sudo -u www-data /var/www/html/occ maintenance:install: no such file or directory”: unknown
Could this be that
occ is not in its place until the container’s first run?
Yes, I’ve tried it with and without php in front of occ in all scenarios.
First you must enter the container:
docker exec -it nextcloudpi /bin/bash
Now the commands will work. This is how containers literally function, by segregating different services in Docker from the host machine via containers. Volumes are actually folders on the host machine. Images are what you pull to define the containers and volumes you end up running.
Continuing the discussion from Inside Dockerfile, using the official Nextcloud Docker image, how do I run occ commands as www-data?:
Thanks, just. My goal is to make a fine-tuned replicable Docker-fied NC instance where all apps and settings can be configured on
docker-compose up -d. Since I cannot instruct
RUN /var/www/html/occ ... in
Dockerfile, am I correct in assuming that:
- I will not be able to run
maintenance:install during image/container creation?
- My best bet is to script the nextcloud install/setup and run after container creation?
Have you tried using Nextcloudpi.com or @Reiner_Nippes setups? There are plenty to choose from and all work well.
# is what defines root privileges on a command when documenting it.
$ defines regular users privileges on a command when documenting it.
People don’t notate RUN or USER. Just fyi.
another quick thought: no need to link this thread, when we are already replying to this thread. You can use the " icon, or quote functionality, if you need to quote something from your earlier post in Discourse (this forum software).
I’ve been running NC on my home server, manually built in LXC for years. I’m just switching to Docker and need things to very specific and would like the install to be infinitely replicable by means of Docker config files or scripting (installing Nextcloud apps, etc.).
“RUN” is notation within a Dockerfile, the file that defines additional layers of a Docker image during creation (as in the title). It normally will allow one to run any command as it is at the command prompt. So
RUN apt install foo is the cli equivalent of
/bin/sh -c apt install foo. In this one situation however,
occ is not found.
I seldom post to forums. Not even sure what I pressed. Noted.
You can set a bash alias to run OCC without having to open a shell on the container first. Replace “nextcloud” below with the container name.
echo alias occ=\'docker exec -it -u www-data nextcloud php occ\' >> ~/.bashrc
if you just use the official nextcloud image with a FROM statement there is no nextcloud installed in it. nextcloud is installed during the first start of the container. (have a look at entrypoint.sh)
you have to put everything in entrypoint.sh
I knew I was looking for something like