App Service Linux WebApp Java 11/TomCat 9 readonly filesystem error

Frans Koning 66 Reputation points
2023-06-02T08:49:19.0366667+00:00

Hi There,

I'm facing an error on an app service with Java 11 and Tomcat 9 runtime. The Linux container starts, but java cannot start due to errors on a read only filesystem.

java.nio.file.FileSystemException: /home/LogFiles/Application/catalina.pl0sdlwk000MX4.2023-03-03.log: Read-only file system

Also, when I SSH login on the container I can confirm the /home directory is somehow readonly:

b648da145290:/home# touch test
touch: test: Read-only file system

How can I resolve this problem?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,931 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VasimTamboli 5,215 Reputation points
    2023-06-04T13:16:32.42+00:00

    By design, the App Service on Linux uses a read-only root filesystem to ensure the integrity and security of the platform. However, it provides a persistent storage option for your application's data.

    To resolve this problem, you should avoid writing or modifying files in the read-only filesystem. Instead, you can utilize the persistent storage provided by Azure App Service to store your application logs and other writable data.

    In the case of Tomcat, you can configure it to write logs and other files to a writable location by specifying a different directory path. By default, Tomcat writes logs to the ${catalina.base}/logs directory, which resides in the read-only filesystem. You can override this configuration by setting the CATALINA_BASE environment variable to a writable path. For example, you can set it to /home/site/wwwroot which is the path to the persistent storage in the App Service.

    To configure the CATALINA_BASE environment variable in your App Service, you can follow these steps:

    1. Open the Azure portal and navigate to your App Service.
    2. Go to the Configuration section.
    3. Add a new application setting with the name CATALINA_BASE and the value /home/site/wwwroot.
    4. Save the configuration.

    After making this configuration change, restart your App Service for the changes to take effect. Tomcat will now write logs and other files to the /home/site/wwwroot directory, which resides in the persistent storage and is writable.

    Remember that any changes made to the container filesystem during the application's runtime will be lost when the container restarts. Therefore, it's essential to store your application's data and logs in a persistent storage location like the /home/site/wwwroot directory or an external storage service.

    By following these steps, you should be able to resolve the read-only filesystem issue in your App Service Linux Web App running Java 11 and Tomcat 9.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.