Error while mounting host directory in Nexus Docker
Asked Answered
R

4

6

I am using the following command to run my container

docker run -d -p 9001:8081 --name nexus -v /Users/user.name/dockerVolume/nexus:/nexus-data sonatype/nexus3

Container starts and fail immediately. with the following logs

mkdir: cannot create directory '../sonatype-work/nexus3/log': Permission denied

mkdir: cannot create directory '../sonatype-work/nexus3/tmp': Permission denied

Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to No such file or directory

I was following this link to set it up I have given said permission to nexus directory.

I also tried the following SO link but that didn't help me either. I was still getting the same error.

Docker Version 17.12.0-ce-mac47 (21805)

[EDIT] I did made changes to the ownership of my nexus folder on my host

sudo chown -R 200 ~/dockerVolume/nexus
Radiotelegraphy answered 30/1, 2018 at 4:6 Comment(2)
Provide Dockerfile, do not just share link.Meshuga
This is from docker hub and I have just pulled it in. I do not have access to dockerfile and they have not added it from github. I did quick check to figure it out but was not able to. I am using docker pull sonatype/nexus3Radiotelegraphy
S
18

In my ubuntu server I had to perform:

chown -R 200:200 path/to/directory

Not only 200, but 200:200

Spendthrift answered 11/4, 2018 at 16:35 Comment(1)
After upgrading 3.37 to 3.41 I had the same problem. Until that it was working with root group. This solved my problem.Strand
H
15

If you have this problem trying to run Nexus3 inside of Kubernetes cluster, you should set UID with initContainers. Just add it to your spec:

initContainers:
- name: volume-mount-hack
  image: busybox
  command: ["sh", "-c", "chown -R 200:200 /nexus-data"]
  volumeMounts:
  - name: <your nexus pvc volume name>
    mountPath: /nexus-data
Highspirited answered 7/10, 2018 at 10:18 Comment(0)
P
3

That Dockerfile is available, in the repo sonatype/docker-nexus3.

And mounting a volume is documented as:

Mount a host directory as the volume.

This is not portable, as it relies on the directory existing with correct permissions on the host. However it can be useful in certain situations where this volume needs to be assigned to certain specific underlying storage.

$ mkdir /some/dir/nexus-data && chown -R 200 /some/dir/nexus-data
$ docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/nexus-data sonatype/nexus3

So don't forget to do, before your docker run:

chown -R 200 /Users/user.name/dockerVolume/nexus
Paddie answered 30/1, 2018 at 5:20 Comment(3)
I did made these changes but am still getting this error. Also I looked it up in SO and found one post (which I have listed above) id nexus given me uid as 200 only.Radiotelegraphy
@Radiotelegraphy Then switch to the recommended approach, and create a data volume: docs.docker.com/engine/admin/volumes/volumes/…Paddie
OR probably try to create an extended Dockerfile & add required permissions using that.Antitoxin
S
0

enter image description here

Nexus Repository stores its data in the /sonatype-work directory by default (check this link)

so instead of /nexus-data try to use /sonatype-work for exp:

docker run -p 8081:8081 -v /data/nexus:/sonatype-work --name nexus -d sonatype/nexus3

Sweepstakes answered 27/9, 2023 at 15:1 Comment(1)
Hi, the use of images for code/errors causes many problems. Please read Why should I not upload images of code/data/errors?. Thank youCaulescent

© 2022 - 2024 — McMap. All rights reserved.