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:
- Open the Azure portal and navigate to your App Service.
- Go to the Configuration section.
- Add a new application setting with the name
CATALINA_BASE
and the value/home/site/wwwroot
. - 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.