'How to avoid creating RUNNING_PID when root file system is read only

Working on k8s deployment of play application(using centos 8) with root file system as read only getting exception as below.

ENTRYPOINT ["java","-Dconfig.file=./conf/sample.conf","-Dhttp.port=9000","-Dpidfile.path=/dev/null","-Xmx4G","-cp",".:./lib/*","play.core.server.NettyServer"]

Exception in thread "main" java.io.FileNotFoundException: /var/run/RUNNING_PID (Read-only file system)
        at java.io.FileOutputStream.open0(Native Method)
        at java.io.FileOutputStream.open(FileOutputStream.java:270)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:162)

workarounds tried so far

  1. Play Framework cannot create RUNNING_PID File in Ubuntu
  2. Play change RUNNING_PID file path
  3. created volume of emptyDir with readOnly false. can able to create file using touch but while pointing the play file path (--Dpidfile.path=volume mount path) it fails to create the RUNNING_PID

but nothing helped. appreciate any help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source