error: could not lock config file error on Container - docker

I'm running a docker container and mounting a volume which needs to be accessed from inside the container and it fails with the below error.
docker run -it -p 8080:8080 -p 29418:29418 -e CANONICAL_WEB_URL=http://ec2-18-21-19-32.us-east-2ompute.amazonaws.com:8080 \
> -v '/home/gerrit/gerrit_instance/gerrit_vol/etc:/var/gerrit/etc' \
> --env CANONICAL_WEB_URL=http://ec2-18-219-190-32.us-east-2.compute.amazonaws.com:8080 gerritimage
error: could not lock config file /var/gerrit/etc/gerrit.config: Permission denied
Docker installed on Ubuntu
If i run this image without the volume it works perfectly. The instant i want to add my custom file this error is reported.
In the container these files are populated automatically with the init script
Link followed to build and execute the file
docker pull gerritcodereview/gerrit
https://github.com/GerritCodeReview/docker-gerrit
The steps are identical and i'm just uploading the etc directory which needs to be mounted to the gerrit container.
Any help is greatly appreciated.
Thank you,
Anish

Related

To which directory should file volume be attached in Kommet Docker

I am running an installation of the Kommet platform, but I trouble figuring out how to attach a volume related to uploaded file storage.
According to Kommet documentation I am supposed to run it with the following command:
docker run -t kommet/kommet -v data-volume:/var/lib/postgresql -d
This works fine and I can see that my database data is properly stored in my data volume. However, Kommet also allows for uploading files, and I cannot figure out where they are stored.
Is there an option to attach another volume to a specific location where uploaded files are kept?
According to Running Kommet as Docker container doc, you must mount a volume at /usr/local/tomcat/webapps/filestorage such as:
docker run -d --name myapp \
-v my-file-storage:/usr/local/tomcat/webapps/filestorage \
-t kommet/kommet
In your case with database volume, it would be something like:
docker run -t kommet/kommet -d \
-v data-volume:/var/lib/postgresql
-v file-volume:/usr/local/tomcat/webapps/filestorage

Chmod permission issue when running a docker container

I'm trying to run a simple-ca container (https://github.com/jcmoraisjr/simple-ca) in docker (running in a fresh install of ubuntu 18.04.4) but every time I run the docker command
docker run --name simple-ca -p 80:8080 -p 443:8443 -e CERT_TLS_DNS=ca.mycompany.com -e CA_CN=MyCompany-CA -v /var/lib/simple-ca/ssl:/ssl quay.io/jcmoraisjr/simple-ca:latest
I get the error
chmod: private: Operation not permitted
I have already granted systemd-network ownership of the folder /var/lib/simple-ca/ and ran the command
/bin/bash -c 'chown $(docker run --rm quay.io/jcmoraisjr/simple-ca id -u lighttpd) /var/lib/simple-ca/ssl'
to grant lighthttpd rights on the SSL folder
Anyone have any idea on what may have went wrong?
It was a permission issue that caused the container to fail to start. I had to remove the folder /var/lib/simple-ca and let the systemd startup re-create it with Lighttpd user id.
Once that was done, I used the container console access to directly edit the CA config files and the whole simple-ca was working as expected.

Trying to run "comitted" Docker image, get "cannot mount volume over existing file, file exists"

I am developing a Docker image. I started with a base image and was working inside it interactively, using bash. I installed a bunch of stuff, and the install (which included compiling a lot of code) took over 20 minutes, so to save my work, I used:
$ docker commit 0f08ac958391 myproject:wip
Now when I try to run the image:
$ docker run --rm -it myproject:wip
docker: Error response from daemon: cannot mount volume over existing file, file exists /var/lib/docker/overlay2/95aa9a9ea7cc0b1ba302adbd287e4d7059ee4fbe64183404df3bc65df332ee63/merged/run/host-services/ssh-auth.sock.
What is going on? How do I fix this?
Note about related/duplicate questions: while there are other questions about this error message, none of the answers directly explain why the error happens in this situation or what to do about it. In fact, most of the questions have no answers at all.
When I ran the base image, I included a mount for the SSH agent socket:
$ docker run --rm -it -v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock myproject:dev /bin/bash
This bind mounts a file from the host (actually the Docker daemon VM) to a file in the Docker container. When I committed the running image, the image contained the file /run/host-services/ssh-auth.sock. The image also contained an empty volume reference to /run/host-services/ssh-auth.sock. This means that when I ran
$ docker run --rm -it myproject:wip
It was equivalent to running
$ docker run -v /run/host-services/ssh-auth.sock --rm -it myproject:wip
Unfortunately, what that command does is create an anonymous volume and mount it into the directory /run/host-services/ssh-auth.sock in the container. This works if the container has such a directory or even if it does not. What causes it to fail is if the target name is taken up by a file. Docker will not mount a volume over a file.
The solution is to explicitly provide a mapping from a host file to the target volume. Any host file will do, but in my case it is best to use the original. So this works:
docker run --rm -it -v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock myproject:wip

Unable to link volume to the rocker/rstudio container on linux

When I execute commands in Ubuntu 18:
cd ~/r-projects
docker run -d -v $PWD:/home/rstudio rocker/rstudio
docker creates rstudio container accessible in localhost:8787. But I can't see the content of the $PWD inside RStudio session. When I save files in RStudio session and then restart the container those files persist, but I can not find them in the host using locate command. It seems that $PWD is not mounted but docker uses another folder to preserve RStudio state.
This is strange behavior. What I really want is to link some folder on the host to the rstudio inside docker container. What am I doing wrong?
Official instructions did not help me.
Please, provide correct command.
I resolved the issue:
docker run -d -p 8787:8787 -e PASSWORD=123 -v $PWD:/home/rstudio rocker/rstudio
The problem was that I executed commands inside kubernetes cluster.

(dockerfile) for flag -v: bad mode specified

I have problems with the introduction of these instructions https://github.com/notabenoid/notabenoid-dockerfile
Out my error command
docker run -v `pwd`:/srv/example.com -p 127.0.0.1:8080:80 --name notabenoid notabenoid
I managed to turn the site, but my goal is to change a few files and pictures
How to edit files to container ?
use docker execto modify some files in a container, see the doc
https://docs.docker.com/engine/reference/commandline/exec/
check also the docs for docker run
https://docs.docker.com/engine/reference/commandline/run/
and the examples with -v
If You only need to change some files use docker cp.
docker run -p 127.0.0.1:8080:80 --name notabenoid notabenoid
docker cp notabenoid:/srv/example.com/file_to_change .
edit file
docker cp file_to_change notabenoid:/srv/example.com/file_to_change
where /srv/example.com/file_to_change is a path to file in container.
edit
Let's Your new logo is /home/Hellioob/new_logo.gif.
docker cp /home/Hellioob/new_logo.gif notabenoid:/notabenoid/site/www/i/logo.gif

Resources