nextcloudpi in docker: Cannot use mounted external storage - docker

Recently I installed nextcloudpi in docker with
sudo docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /home/user/storage/nextcloud:/data --name nextcloudpi ownyourbits/nextcloudpi-armhf <ip-adress-of-pi>
the folder /home/user/storage is a mounted external storage (following this tutorial https://www.techjunkie.com/build-nas-raspberry-pi-linux/)
It get me the error:
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)
If running with 'docker exec' try adding the option '-u root' to the docker command (without the single quotes)
I tried
sudo docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /home/user:/data --name nextcloudpi ownyourbits/nextcloudpi-armhf <ip-adress-of-pi>
and everythink workes well as far as I can tell. I can load the nextcloudpi config UI as well as the nextcloud GUI.
I have tried some chown and chmod for the /home/user/storage folder, without any succes.
How can i use the external storage as directory of the nextcloud?

Related

docker: open /.env: no such file or directory

Goal
Action: Run command from my local machine
Result: Docker image deployed on cloud instance
Approach
For remote deployment, I am using gcloud commands.
The command below is working but the only problem is that it is not picking environment variables file i.e. .env. I have this .env file placed in the working directory.
Command:
gcloud beta compute ssh --quiet --zone "us-west1-b" "devop-beta-persistent-2" --project "my-project" --command 'sudo docker run -p 8080:8080 -p 8443:8443 -p 50000:50000 -v ~/jenkins_data:/var/jenkins_home -v $FILE_PATH/jenkins.yaml:/var/configurations/jenkins_casc.yml --name jenkins-devkit --env-file $PWD/.env $JENKINS_IMAGE:latest'
Error: docker: open /.env: no such file or directory.
What I already tried
I have tried setting path to:
.env
/full/path/to/.env
$PWD/.env
but still getting the same error.
If I run this command on my local machine, it works fine i.e. picking up the .env file.
sudo docker run -p 8080:8080 -p 8443:8443 -p 50000:50000 -v ~/jenkins_data:/var/jenkins_home -v $FILES_PATH/jenkins.yaml:/var/configurations/jenkins_casc.yml --name jenkins-devkit --env-file $PWD/.env $JENKINS_IMAGE:latest
Can any one suggest the possible solution?

Docker how to pass a relative path as an argument

I would like to run this command:
docker run docker-mup deploy --config .deploy/mup.js
where docker-mup is the name the image, and deploy, --config, .deploy/mup.js are arguments
My question: how to mount a volume such that .deploy/mup.js is understood as the relative path on the host from where the docker run command is run?
I tried different things with VOLUME but it seems that VOLUME does the contrary: it exposes a container directory to the host.
I can't use -v because this container will be used as a build step in a CI/CD pipeline and as I understand it, it is just run as is.
I can't use -v because this container will be used as a build step in a CI/CD pipeline and as I understand it, it is just run as is.
Using -v to expose your current directory is the only way to make that .deploy/mup.js file inside your container, unless you are baking it into the image itself using a COPY directive in your Dockerfile.
Using the -v option to map a host directory might look something like this:
docker run \
-v $PWD/.deploy:/data/.deploy \
-w /data \
docker-mup deploy --config .deploy/mup.js
This would map (using -v ...) the $PWD/.deploy directory onto /data/.deploy in your container, set the current working directory to /data (using -w ...), and then run deploy --config .deploy/mup.js.
Windows - Powershell
If you're inside the directory you want to bind mount, use ${pwd}:
docker run -it --rm -d -p 8080:80 --name web -v ${pwd}:/usr/share/nginx/html nginx
or $pwd/. (forward slash dot):
docker run -it --rm -d -p 8080:80 --name web -v $pwd/.:/usr/share/nginx/html nginx
Just $pwd will cause an error:
docker run -it --rm -d -p 8080:80 --name web -v $pwd:/usr/share/nginx/html nginx
Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to
delimit the name
Mounting a subdirectory underneath your current location, e.g. "site-content", $pwd/ + subdir is fine:
docker run -it --rm -d -p 8080:80 --name web -v $pwd/site-content:/usr/share/nginx/html nginx
In my case there was no need for $pwd, and using the standard current folder notation . was enough. For reference, I used docker-compose.yml and ran docker-compose up.
Here is a relevant part of docker-compose.yml.
volumes:
- '.\logs\:/data'

How can I save zeppelin notebook from a docker?

I am using a docker-container for spark-zeppelin. The docker image was fund here,
https://github.com/Gmousse/docker-zeppelin-python3
I can start an image and work using this command,
docker run -it -p 8080:8080 -p 8081:8081 gmousse/docker-zeppelin-python3
To be able to communicate with the host, I have mounted some paths to host with volume flag like this,
docker run -it -v /cephfs:/cephfs -p 8080:8080 -p 8081:8081 gmousse/docker-zeppelin-python3
it works fine. Now to mount the zeppelin working directory I added this,
docker run -it -v /cephfs:/cephfs -v my_path_on_host:/zeppelin -p 8080:8080 -p 8081:8081 gmousse/docker-zeppelin-python3
And this does not run.
In this command actually it is looking for a zeppelin.sh file in /zeppelin and fails.
Any idea, how can I mount a local volume, and be able to save zeppelin notebook on the host?
Thank you for your time, in advance...
It is very handy to store notebooks on local file system especially under version control.
So you need to mount only notebook folder, but you tried to mount whole zeppelin folder and on start container could not find zeppelin files.
Correct mount examples:
docker run \
-p 8080:8080 \
-v /home/user/zeppelin_notebooks:/zeppelin/notebook \
apache/zeppelin:0.8.0
docker run \
-p 8080:8080 \
--mount type=bind,source="$(pwd)"/zeppelin_notebooks,target=/zeppelin/notebook \
--rm --name zeppelin apache/zeppelin:0.8.0
for My apache zeppelin docker hosted on window 10, the pwd is /opt/zeppelin, the default path for notebooks is /opt/zeppelin/notebook, so I mount my window path as below, Therefore, All notebooks are being save in "C:/Zeppelin/notebook"
docker run -p 8080:8080 -v C:/Zeppelin/Data/:/opt/zeppelin/Data/ -v C:/Zeppelin/notebook:/opt/zeppelin/notebook --name zeppelin apache/zeppelin:0.10.0

Docker ignores local project

I'm trying to run a local project folder with apache, seems to default to the server message of "It works" instead of running my project folder. When I go to 127.0.0.1:8080
sudo docker run -d -p 8080:80 -v "$PWD:/home/me/public_html/project-folder" httpd
I'm using ubuntu desktop
you need to mount the location of your project to this directory in the container: /usr/local/apache2/htdocs/
try this:
sudo docker run -d -p 8080:80 -v "/home/me/public_html/project-folder:/usr/local/apache2/htdocs" httpd
this is explained here: https://hub.docker.com/_/httpd/

Docker user permission while mounting a directory

I am using the following Dockerfile to build Solr using Docker.
FROM solr:5.5
ENV SOLR_HOME=/opt/solr/server/solr/cores
RUN mkdir ${SOLR_HOME}
RUN chown -R solr:solr ${SOLR_HOME}
VOLUME ["${SOLR_HOME}"]
EXPOSE 8983
I try to run the following Docker command to mount a host directory to the container:
docker run --restart=always -d --name solr-demo \
--privileged=true -p 8983:8983 \
-v /data/solr_demo:/opt/solr/server/solr/cores \
solr-test:latest
I am also copying the required solr.xml file into the data/solr_demo. When I run the docker run command I get the following error:
stat: cannot stat ‘/opt/solr/server/solr/cores’: No such file or directory 42146d74b446ba4784fd197688e3210f294aad8755ae730cc559132720bcc35a
Error response from daemon: Container 42146d74b446ba4784fd197688e3210f294aad8755ae730cc559132720bcc35a is restarting, wait until the container is running
From your comment, it appears you're mounting a nonexistent directory for your volume. Try this command that mounts /data/solr_demo1 instead of /data/solr_demo as your volume.
docker run --restart=always -d --name solr-demo \
--privileged=true -p 8983:8983 \
-v /data/solr_demo1:/opt/solr/server/solr/cores \
solr-test:latest
If it is really an user problem (it remind me of some issue I add with apache in container), you should consider using Gosu. https://github.com/tianon/gosu
It will let you run and swap user correctly and have a nice mapping from your local users and users inside the container.
Hope it will be useful.

Resources