sonatype / docker-nexus

Docker image for Sonatype Nexus
Other
383 stars 201 forks source link

Can't re create a docker from existant image and volumes #95

Closed RomainPhil closed 4 years ago

RomainPhil commented 4 years ago

Hi, I've create a first container with a docker compose

services:
  nexus:
    image: sonatype/nexus3
    volumes:
      - "/etc/nexus/nexus-data:/nexus-data"
    ports:
      - "8081:8081"
volumes:
  nexus-data: {}

after having config it, would like to create a new image and keep the configuration.

so i launch the Dockerfile below in /etc/nexus

FROM sonatype/nexus3:3.22.0

ADD nexus-data ./nexus-data
EXPOSE 8081

i got the following issue :

OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to Permission denied

Warning:  Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
Warning:  Forcing option -XX:LogFile=/tmp/jvm.log
java.io.FileNotFoundException: ../sonatype-work/nexus3/tmp/i4j_ZTDnGON8hezynsMX2ZCYAVDtQog=.lock (Permission denied)
        at java.io.RandomAccessFile.open0(Native Method)
        at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
        at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
        at com.install4j.runtime.launcher.util.SingleInstance.check(SingleInstance.java:72)
        at com.install4j.runtime.launcher.util.SingleInstance.checkForCurrentLauncher(SingleInstance.java:31)
        at com.install4j.runtime.launcher.UnixLauncher.checkSingleInstance(UnixLauncher.java:88)
        at com.install4j.runtime.launcher.UnixLauncher.main(UnixLauncher.java:67)
Unable to delete file: /nexus-data/cache/bundle233/version0.0/revision.location
Unable to update instance pid: /nexus-data/instances/instance.properties (Permission denied)
Exception in thread "Thread-2" java.lang.SecurityException: Could not lock User prefs. Lock file access denied.
        at java.util.prefs.FileSystemPreferences.checkLockFile0ErrorCode(FileSystemPreferences.java:949)
        at java.util.prefs.FileSystemPreferences.lockFile(FileSystemPreferences.java:937)
        at java.util.prefs.FileSystemPreferences.sync(FileSystemPreferences.java:741)
        at java.util.prefs.FileSystemPreferences.flush(FileSystemPreferences.java:836)
        at java.util.prefs.FileSystemPreferences.syncWorld(FileSystemPreferences.java:476)
        at java.util.prefs.FileSystemPreferences.access$1200(FileSystemPreferences.java:50)
        at java.util.prefs.FileSystemPreferences$4$1.run(FileSystemPreferences.java:454)

i've check the permission and the user with a modification into the docker file and the user configured into my copied files i've got the nexus:nexus as owner and 755 for folder and 644 for file.

RomainPhil commented 4 years ago

So i found a solution,

from this Dockerfile who cause the errors

FROM sonatype/nexus3:3.22.0  
USER root:0 
RUN rm -Rf ./nexus-data/* 
COPY ./nexus-data ./nexus-data 
RUN chown -R nexus:nexus nexus-data 
EXPOSE 8081 
USER nexus:200

to this one who doesn't raise an error, it seems the same for me but it works


FROM sonatype/nexus3:3.22.0  
USER root:0 
COPY --chown nexus:nexus ./nexus-data ./nexus-data 
EXPOSE 8081 
USER nexus:200

if anyone had a answer why i'm interest, otherwise you can close this issue