Getting PHP Error Logs in Docker

I have a PHP app which is deployed using Docker (Caprover setup, but that does not matter from what I understand).
I have a webhook configured, which has been failing a lot lately. It sometimes finishes itself as well.
I tried moving all my steps inside a Try/Catch block and capture the error, but no luck so far.
I can see from Portainer logs that the request has been received on the server & the response is 500.

How do I see what the actuall error is? Its a production app and I have no idea why is the error being generated in the first place… while few hooks are also getting processed correctly.

I have tried setting Beeceptor in parallel with my app’s URL, and while Beeceptor just shows regular POST request with body & headers… my app is failing to process it all.
Could the size of the request POST body be a cause of this issue? Its 40-55K+ characters in the cases where its failing. I am able to store this information in DB, and it has almost filled up the “text” field in my MySQL DB which has a length of ~65K characters.

Please help.

While I was writing this, the request size has increases even more, and now the Try/Catch is working just to record the $_ERROR value that data is too long for the column.
I guess every failed request from the webhook provider is accumulating newer requests into the next hook - increasing the POST body size.


I don’t know what kind of data you have, but seems you have to update the database to support the data size or truncate the data so it will fit in the column. In MySQL you could use the MEDIUMTEXT or LONGTEXT to support more then 64K characters.

Thats not the issue here.
I can change the data type of column to see the post body.

I need a way to view PHP 500 error which is being returned to the webhook.

You say a try/catch didn’t capture the error, what kind of actions do you do in the webhook?

I just read the POST body, and insert data in the DB.


  1. Insert log with start time & POST body.
  2. Check condition that there should be some types of headers available & POST should have id value.
  3. Continue with rest of the steps of inserting in DB.
  4. At last, update the log with completed time.
  5. In case of error, record $_ERROR in log.

When the hook processing works, I can see point 4 working. So I know the setup works.
But when I see 500, only step 1 runs. There is no Catch log entry.

@patrick Please help. Still haven’t found any solution for this.

Have tried numerous options in the last two days, but none of them is logging the actual error in docker logs.
What I see is something like - - [31/Dec/2021:03:05:28 +0000] "POST /api/Sync/Shopify/hook_product.php HTTP/1.0" 500 4094 "-" "Shopify-Captain-Hook"

But the error behind this 500 response is nowhere to be found. Please help @patrick

That’s nginx’s access log, not error log. You need to find the error log

Try /var/log/nginx (I don’t know where CapRover stores nginx’s logs)

Find CapRover’s nginx container by doing “docker ps”. Imagine it’s 26c969f50f05:

docker container exec -it 26c969f50f05 bash
cd /var/log/nginx
tail error.log

Thanks for the insight.
I tried trailing nginx docker’s error.log, but it did not return anything. No ouptut from the command.

I then tried looking at regular logs of the nginx docker, and found similar entry as in actual app’s docker.
One additional line before that was

523060 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000007997

But this was in both 200 & 500 response cases.

Any other ideas? This is becoming a nightmare to debug.

Well per default in Docker php configurations the error logging is off specially on production environments.


When you enable debug in server connect we do output any errors though.

Thanks you for the link.
I have enabled logging but it still doesn’t output anything. Debug is on in server action settings as well.

Here is my docker file:

FROM library/php:7.4.22-apache

RUN echo 'max_execution_time = 0' >> /usr/local/etc/php/conf.d/docker-php-max_execution_time.ini && \
	echo 'memory_limit = 2000M' >> /usr/local/etc/php/conf.d/docker-php-memory_limit.ini && \
	echo 'upload_max_filesize = 4M' >> /usr/local/etc/php/conf.d/docker-php-upload_max_filesize.ini && \
	echo 'post_max_size = 4M' >> /usr/local/etc/php/conf.d/docker-php-post_max_size.ini && \
	echo 'max_input_time = -1' >> /usr/local/etc/php/conf.d/docker-php-max_input_time.ini && \
	echo 'max_input_vars = 3000' >> /usr/local/etc/php/conf.d/docker-php-max_input_vars.ini && \
    echo 'log_errors = On' >> /usr/local/etc/php/conf.d/docker-php-error_log.ini && \
	echo 'error_log = /dev/stderr' >> /usr/local/etc/php/conf.d/docker-php-error_log.ini

RUN apt-get -qq update && \
	apt-get -qq install -y ca-certificates nano cron zip unzip git && \
	apt-get -qq autoclean -y && \
	apt-get -qq autoremove -y

ADD /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
    install-php-extensions mysqli pdo pdo_mysql

RUN rm -rf /var/lib/apt/lists/*

COPY ./ /var/www/html/
RUN mkdir -p /var/www/html/Downloads

RUN chown -R www-data:www-data /var/www && \
	chmod 755 /var/www/html

RUN a2enmod rewrite

RUN rm -rf /root/.composer /var/lib/apt/lists/* /var/www/html/.git* /var/www/html/captain-definition /var/www/html/Dockerfile /var/www/html/myDockerFile /var/www/html/MyDockerFile

I have confirmed with phpinfo() as well that log errors is on.

To see the error in the docker output logs they should be outputted in the regular stdout and not stderr

Then you should see them in the web server logs, even in real time.

Also for more docker php configuration options see:

Do you mean changing error_log = /dev/stderr to error_log = /dev/stdout ?
I tried that but I don’t see any change in output logs.

log_errors = On is enough you don’t need to specify error_log as you don’t won’t to log to file

what errors are you expecting to see but you don’t?

Hello @sid Does this error happen occasionally? Also, are you using mysql in a docker container?

Try checking the php container, find Apache logs just like we tried for nginx

This. I have setup one of my SA as URL for webhook.
When the request comes in, it mostly fails with 500… And randomly gets processed as well with 200.

I need to see what this 500 error is.

Hi Serhat. Its from a webhook. So most of the calls fail, few get processed correctly.

MySql is in a separate non-docker server instance.