-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't start container if volume mounted from a dedicated container #31
Comments
I had the same problem and I solved by removing the user nexus commands |
Os: centos 7 Unable to start nexus docker file with command: docker run -d -p 8081:8081 -p 5000-5005:5000-5005 -v /var/lib/nexus-data:/nexus-data --name nexus sonatype/nexus3 I created the directory: The container fail for permissions startup: docker logs -f nexus Only solution I found is to start it with z switch for root access over that mounted directory. M B |
using su-exec to solve the issue:
|
there is a temporary solution , plz refer to OpenShiftDemos/nexus#5 (comment) |
FROM sonatype/nexus3
RUN chown -R ${NEXUS_USER}:${NEXUS_USER} ${NEXUS_HOME} ${NEXUS_DATA} ${SONATYPE_WORK} |
Was running into this issue in Kubernetes, solved by adding a securityContext:
fsGroup: 2000 |
An ugly fix: Run it as root user.. docker run -u 0 .... |
Note to future readers: the correct security context is securityContext:
fsGroup: 200 |
I have created the following volume with cockpit |
i am trying to run a nexus instance on a k8s cluster provided by rancher 2.x. the problem is that the volume mount for a) find the directory of the mount in the local file system and change the file mode (assuming you have named the created subdirectory
one of the listed directories is the mounted volume. then change the ownership with
as you may have observed, the mode is now b) execute a shell in the container as root and change ownership: the container command must be changed to get into the container:
which gives you the container id. now execute a shell as follows:
then execute
then quit, remove the see also: https://github.com/sonatype/docker-nexus3/blob/master/Dockerfile |
Thanks @cilindrox !! |
changing secgroup doesn't work for me.
|
user below parameter in deployment file. |
I did the same thing and solved it. But I am not sure if it would cause security and/or stability issues |
You just need to change the ownership of the directory where you are trying to mount, nothing else. |
@nik0811 Thank you for posting that. That's exactly the type of command I was trying to figure out. It worked perfectly for me. |
Official Docker container description mentions: https://hub.docker.com/r/sonatype/nexus/ :
In case you have separate VM for Nexus container, you could also change UID/GUID of host user to 200. |
For us, running on OpenShift, we got it working by using:
(And then had to ensure our serviceAccount was permitted to use this ID via the appropriate SCC). We also tried using
|
you have to make sure the directory you mount to nexus has 200:200 as owner as well. So not only the blobs, cache, etc directories, but the root directory mounted to the container |
Try disabling selinux , it always works for me |
FWIW, here's how I solved it on docker compose:
|
I'm using following correct deployment config for k8s. Also there are some issues with kvaps/nfs-server-provisioner and you should use v1.4.0 with default NFS v3
|
I worked around the issue using the initContainer solution originally proposed by chz8494. Using fsGroup did not work for me as well. I'm deploying in AWS Kubernetes. I could be mistaken. But it seems like to me that is problem has a wide impact. All users that attempt to deploy Nexus3 in a container or container orchestrator with a persistent volume under /nexus-data will waste some time troubleshooting why Nexus can't write to the folder. And the prevention of the issue also seems to me rather simple on the Sonatype side. Just needs one line of code in the Dockerfile as proposed by Yavin. Therefore it seems to me a low hanging fruit on the Sonatype side that can save a few minutes (or hours) from everyone deploying Sonatype3 on containers for the first time. In the 6 years between issue reporting and today I would assume a large number of wasted hours have accumulated by everyone that first deployed it in containers. Also I suggest updating the issue description to: |
If /sonatype-work volume is mounted from a dedicated data container :
sudo docker create --name nexus-data -v /var/lib/nexus:/sonatype-work busybox
sudo docker create --name nexus-server --volumes-from nexus-data sonatype/nexus
Container cannot start :
sudo docker start nexus-server
Data container, as the server container itself, must be created from sonatype/nexus docker image, what is weird IMO.
sudo docker create --name nexus-data -v /var/lib/nexus:/sonatype-work sonatype/nexus
As far as I know, Nexus is the only docker image which require such a constraint.
The text was updated successfully, but these errors were encountered: