While running a java code in a docker container with root user, getting permission denied error.
Java Code
File f = new File("example.xlsx");
f.createNewFile(); // error at this line
Error:
ava.io.IOException: Permission denied
at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:na]
at java.base/java.io.File.createNewFile(File.java:1035) ~[na:na]
The docker image created with the docker file
FROM docker:dind
USER root
RUN apk add curl maven openjdk11
RUN wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.10.0/allure-commandline-2.10.0.zip
RUN unzip allure-commandline-2.10.0.zip -d /
RUN export PATH="${PATH}:/allure-2.10.0/bin"
and container created using command
docker run -d -p 8080:8080 --add-host="dockerhost:${DOCKERHOST_IP}"
-e parameter
--name app ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_ID}