I have the umask set up on my Apache2 server using umask 002. This is added to the end of /etc/apache2/envvars during the docker container build.

I have the following script to test:

// Create file
if ($fp = fopen(time() . '.txt', 'w')) {
    fwrite($fp, 'This is a simple test.');
    echo "done";
} else {
    echo "error - cannot create file";

// Generate error
error_log("This be an error", 0);

This creates 2 files: error_log_dev (as set in my php.ini) and 1520215096.txt. The permissions for each of these files are as follows:

-rw-rw-r--  1 www-data www-data   22 Mar  5 11:58 1520215096.txt
-rw-r--r--  1 www-data www-data   55 Mar  5 11:58 error_log_dev

Why would the error log not be abiding by the umask but fopen() does?

  • Oh, I missed that bit. OK, I suspect you should read askubuntu.com/a/147065/75668 – Michael Hampton Mar 5 '18 at 4:16
  • @MichaelHampton Thanks Michael. What I take away from that is I need to run service apache2 stop and then service apache2 start. The problem is, that will kill the docker image. Any suggestions? – Wildcard27 Mar 5 '18 at 22:21
  • Debian builds of a lot of software do very strange things, and you've run into one of them. You'll likely need to set the umask in your own docker-entrypoint script. – Michael Hampton Mar 5 '18 at 23:30
  • @MichaelHampton You mean set the umask system-wide on init? – Wildcard27 Mar 7 '18 at 9:07
  • 1
    If that's the script you call from CMD/ENTRYPOINT, then yes. – Michael Hampton Mar 8 '18 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.