5

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
Anunay
  • 1,823
  • 2
  • 18
  • 25
  • Provide Dockerfile, do not just share link. – Shahriar Jan 30 '18 at 04:16
  • 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/nexus3** – Anunay Jan 30 '18 at 04:25

3 Answers3

16

In my ubuntu server I had to perform:

chown -R 200:200 path/to/directory

Not only 200, but 200:200

4lberto
  • 505
  • 6
  • 14
  • 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. – Mert Ülkgün Aug 23 '22 at 17:43
11

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
Stepan Mozyra
  • 212
  • 2
  • 6
1

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
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 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. – Anunay Jan 30 '18 at 05:32
  • @Anunay Then switch to the recommended approach, and create a data volume: https://docs.docker.com/engine/admin/volumes/volumes/#create-and-manage-volumes – VonC Jan 30 '18 at 05:33
  • OR probably try to create an extended Dockerfile & add required permissions using that. – vivekyad4v Jan 30 '18 at 05:45
  • Will try that out as well. Thanks – Anunay Jan 30 '18 at 05:46