Reputation: 380
I did write the following Dockerfiler:
FROM openjdk:8-jdk-alpine
RUN addgroup -g 999 -S appgroup && \
adduser -u 999 -S appuser -G appgroup
USER appuser
COPY myapp.jar /usr/app/myapp.jar
ENTRYPOINT ["java","-jar","/usr/app/myapp.jar"]
When I run the image, I get the follwing error:
main ERROR Unable to create file logs/file.log java.io.IOException: Could not create directory /logs
Could you please tell me what I did wrong?
Upvotes: 0
Views: 2615
Reputation: 11267
User appuser
does not have write permissions in the current working directory (/
, you can verify it with docker run --rm openjdk:8-jdk-alpine pwd
), and it seems that your application needs to create a logs/
directory in that working directory.
Possible solutions :
WORKDIR
to a place he can write (/tmp
for example, or /home/appuser
if it is created) in the Dockerfile
--workdir /path/to/a/folder/where/appuser/can/write
when issuing docker run
command/logs
folder with right permissions (write for appuser
)Upvotes: 4