Using Blackfire with Docker

By Fabien Potencier, on Jan 06, 2015


Docker is everywhere! And today, I’m very excited to announce that Blackfire now fully supports Docker as a platform.

Docker is a great way to isolate processes and being able to isolate the Blackfire Agent or the Blackfire Client in their own containers is now easily possible via the officialblackfire/blackfire image.

The first example I want to show you is how you can use the Blackfire Docker image to easily profile remote web servers… without having to install anything on your machine (the Docker image size is less than 18Mo.)

Run a blackfire/blackfire container and pass the curl command you want to execute:

Create an alias to make it less verbose:

And use the alias like this:

The Docker Blackfire image also comes with the Blackfire Agent daemon:

As the image exposes the Agent socket, linking it to your PHP container is very easy. Here is a simple PHP Dockerfile that illustrates how to add the Blackfire PHP probe:

The ${BLACKFIRE_PORT} variable is the magic that makes it easy to link the PHP container to the agent one:

where php-blackfire is the name of the image you built with the above Dockerfile configuration.

If you are a Docker user, common use cases are explained with detailed examples in our updated documentation:

Happy profiling!

Fabien Potencier

Fabien Potencier is the CEO and founder of He founded the Symfony project in 2004 as he constantly looked for better ways to build websites. Fabien is also the creator of several other Open-Source projects, a writer, a blogger, a speaker at international conferences, and the happy father of two wonderful kids.