29

I try to run a Yii based PHP application in a Docker container using the official php-fpm image.

It's common practice for docker containers to write all log messages to stdout / stderr. So I do the same from my container with a code that basically looks like this:

$fp = @fopen('php://stdout','w');
fwrite($fp, $message);
fclose($fp);

Unfortunately PHP-FPM now prefixes all my log messages with ugly warnings:

[21-Mar-2016 14:10:02] WARNING: [pool www] child 12 said into stdout: "2016-03-21 14:10:02 [x.x.x.x][-][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\debug\Module::bootstrap()" [21-Mar-2016 14:10:02] WARNING: [pool www] child 12 said into stdout: "2016-03-21 14:10:02 [x.x.x.x][-][-][info][yii\web\Session::open] Session started" ...

Why is this and is there a way to prevent PHP-FPM from doing this?

UPDATE:

  1. I've also opened an issue at the docker-library/php project site.
  2. They already include the catch_workers_output = yes in their configuration. So that's not the solution.
  3. According to these changes the problem should be fixed in PHP 7.3
Michael Härtl
  • 8,428
  • 5
  • 35
  • 62
  • I think that it's a common bug https://github.com/heroku/heroku-buildpack-php/issues/63 that it was fixed in version 44, can you confirm ? – Halayem Anis Mar 21 '16 at 14:58
  • @HalayemAnis Can't confirm. As you should see from the problem description I don't use heroku. It's more a misbehaviour of php-fpm in general. – Michael Härtl Mar 21 '16 at 15:02
  • 1
    You tried playing with the `catch_workers_output` option in your `php.ini`? Not sure if that will work or not. – Pitchinnate Mar 21 '16 at 15:07
  • hope this thread might help you http://stackoverflow.com/a/10546138/4098311 – Halayem Anis Mar 21 '16 at 15:19
  • @HalayemAnis Thanks, I've seen that. This configuration is already in place in the official docker image (https://github.com/docker-library/php/blob/d7176685dfad98d1e472557b10534c89fb0693ec/5.6/fpm/Dockerfile#L99). Unfortunately to no avail. – Michael Härtl Mar 21 '16 at 15:49
  • There's been an update to your [Github issue](https://github.com/docker-library/php/issues/207) this week, any luck with that solution? – miken32 Feb 07 '17 at 01:06
  • @miken32 I didn't try it. There are other workarounds, all require you to mess around with `CMD` - something I don't want to do. – Michael Härtl Feb 07 '17 at 07:37
  • 1
    @MichaelHärtl, Hats off to your efforts, I just seen on : https://github.com/docker-library/php/issues/207 – LuFFy Feb 24 '17 at 06:49

2 Answers2

1

It is correct. you are running php-fpm and error logs are from php-fpm , not from PHP . you should expect php-fpm log , not php log. fortunately php-fpm will write every log that received from PHP in end of its logs.

Ehsan Chavoshi
  • 681
  • 6
  • 10
0

Above Php7.3 Use decorate_workers_output = no in php.conf

AgE
  • 387
  • 2
  • 8