0

I have a Java application that is running in the container, and I have removed the core jar file from the container, but still the application in the container is UP and RUNNING, I don't understand how ?

If a Java application is running on our local system, then you can't remove or modify the jar files that are currently used by the application. Even if you try to delete the jar file, you will get the prompt message "The action can't be completed because the file is open in Java Platform Architecture".

How are the host OS processes used in the Docker container? Can someone please explain how this works?

To recreate the scenario: Please download the Tomcat image from the docker hub. Create and run the container using the command (docker run -it --rm -p 8888:8080 tomcat), Now, open the webpage on localhost:8888, and you will see the webpage as HTTP Status 404: Not Found (that's OK - this is expected). Now, the container is UP and RUNNING.

Go inside the container and try to delete the jar files in the lib directory (full path: /usr/local/tomcat/lib) using the command (rm jar-file-name). and please check the web page again, now you will see the same page, where the application is running properly, even after the jar files are removed.

4
  • 2
    How did you remove the far file in a running container? One fundamental difference is that on Unix-likes by default opening a file is non-exclusive: others can open, write to and even delete files that a process have opened. If they delete it the process having previously opened it will continue to be able to read it until it closes it. That might be what you're seeing, but if you could explain what exactly you're doing, we could give a more definite answer. Commented Sep 21, 2023 at 14:06
  • Hi @JoachimSauer, I've updated the post with more explanation, what I'm exactly doing with the basic repro steps. Please check. Thanks Commented Sep 21, 2023 at 15:18
  • 2
    Docker containers runs under linux sybsystem on Windows. In linux you can delete a file which is opened by a process and the file will still be available to running process until the process closes that file or exit. This is precisely what is happening in your case. Commented Sep 21, 2023 at 15:25
  • Thanks for the explanation, @JasvantSingh Commented Sep 21, 2023 at 15:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.