Hello, I have a docker image which is a java application that performs reading of a file and when it finishes executing it generates a new log file. However, the log file is not being saved.
COPY contador.jar /home/brena/app/contadocker/contador.jar
COPY ArquivoGerado.txt /home/brena/app/contadocker/ArquivoGerado.txt
ENTRYPOINT ["java", "-jar", "/home/brena/app/contadocker/contador.jar"]
CMD ["/home/brena/app/contadocker/ArquivoGerado.txt", "1"]
To run I use the following command:
sudo docker run --name containerName imageName
Can someone tell me how to solve it?
What it the path of the file that you expect to generate?
Does the java application have access to this path?
You could create this file manually from inside the container, using for example "echo "test > /path/generated/file " to verify that the container does not have any problem.
You should probably create a volume to store the data that you want to persist after the container is deleted.
The file path that I expect the file to be generated is:
The application is working perfectly when running on linux, the problem lies when running in the container. I checked as you suggested and the container has no problem.
How do I create the volume in this case?
So it looks like the application will generate the file in a path under the home directory of user “brena”.
Is the user “brena” defined in the container OS ??
Note that only “root” and “brena” users have permission to write a file under the “/home/brena/app/contadocker/”
There are many ways to create a volume.
Following is just simple example:
docker run -v my_volume:/world /home/brena/app/contadocker <your_image_name>
Note that the directory “/home/brena/app/contadocker/” should already exist inside the container