Write logs in PHP outside Docker container

8/18/2016

I have a task to write logs outside the docker container. It's a bit problem because I cannot save logs inside the container and we decided to use docker pipe. As you maybe know docker provides logs based on pipes inside Linux. The same approach using in Docker PHP-FPM. So my solution is:

$rs = popen("cat - > /proc/1/fd/1", 'w');
fwrite($rs, "Test" . PHP_EOL);
pclose($rs);

What do you think about it?

-- Ilya Isaev
docker
kubernetes
php

0 Answers