I've recently migrated an event subscription service called by a bash script from Ubuntu, into a Dockerised container.

The Docker image I am using is: FROM php:7.1-apache

The script itself is pretty straightforward:


DIR="$(dirname $0)"

while true
    OUTPUT=$OUTPUT$(php $DIR/../bin/cli.php bash:v1:issueEvents)
    OUTPUT=$OUTPUT$(php $DIR/../bin/cli.php bash:v1:processCustomerAccountEventSubscriptions)
    OUTPUT=$OUTPUT$(php $DIR/../bin/cli.php bash:v1:processProductionOrderEventSubscriptions)
    OUTPUT=$OUTPUT$(php $DIR/../bin/cli.php bash:v1:processWebEnquiryEventSubscriptions)
    OUTPUT=$OUTPUT$(php $DIR/../bin/cli.php bash:v1:processWebOrderEventSubscriptions)
    OUTPUT=$OUTPUT$(php $DIR/../bin/cli.php bash:v1:processWebQuoteEventSubscriptions)

    if [ -z "$OUTPUT" ]; then
        sleep 10

A complete round trip from event subscription to processing would take about 30 seconds on the host OS. Inside a container it is taking around 10 minutes.

My initial suspicion was that DNS was slowing things down, but I've installed dnsutils and the lookup times are the same both inside and outside the container.

I'd like advice regarding how I'd go about investigating the cause of this slowdown.

1 Answer 1


The general process of debugging inside the container is the same as debugging outside of one. The only thing that you generally need to know is that you can use docker exec to attach a bash shell inside a running container, or override the command with --entrypoint to launch bash instead, and then run the script manually.

At that point, your question becomes "How do I debug slow execution times in a PHP script?". That is not really in scope for this site, but you can start with a few basic things: add print statements or attach a profiler to see where things are getting slow, and then narrow it down from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.