<?php
error_reporting(0);
try {
$rc=200;
if (!fopen("check_readonly.txt", "w+")) throw new Exception('File open failed');
if (!fwrite($fp, "s")) throw new Exception('File write failed');
}
catch (Exception $e) {
$rc=500;
}
finally{
http_response_code($rc);
}
exit;
$ docker run -d -w /var/www/html -it -v $PWD/:/var/www/html:ro -p 9004:80 --rm php:8-apache
$ curl -I localhost:9004/readonly.php
HTTP/1.1 500 Internal Server Error
Date: Thu, 16 Dec 2021 01:28:26 GMT
Server: Apache/2.4.51 (Debian)
X-Powered-By: PHP/8.1.0
Connection: close
Content-Type: text/html; charset=UTF-8
$ docker run -d -w /var/www/html -it -v $PWD/:/var/www/html:rw -p 9005:80 --rm php:8-apache
$ curl -I localhost:9005/readonly.php
HTTP/1.1 200 OK
Date: Thu, 16 Dec 2021 01:28:45 GMT
Server: Apache/2.4.51 (Debian)
X-Powered-By: PHP/8.1.0
Content-Type: text/html; charset=UTF-8