Docker Guide

This guide will help you set up pyroscope with Docker.

Examples

Check out the examples folder in our repository for examples of go, ruby and python apps running in docker with pyroscope.

Pyroscope Server

Pyroscope Server is the database + UI that stores and visualizes profiling data.

Running pyroscope server from docker is pretty straighforward, we have a docker image that exposes port 4040:

docker run -it -p 4040:4040 pyroscope/pyroscope:latest server

Open http://localhost:4040/ to see Pyroscope UI.

Pyroscope Exec (Python / Ruby)

To profile your Python or Ruby code running inside a docker container you'll first need to add pyroscope binary to that Docker container so that you could use pyroscope exec command.

To add pyroscope binary to your docker image, use COPY --from command:

# this copies pyroscope binary from pyroscope image to your image:
COPY --from=pyroscope/pyroscope:latest /usr/bin/pyroscope /usr/bin/pyroscope
ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope-server.local:4040
ENV PYROSCOPE_APPLICATION_NAME=my.python.app
CMD [ "pyroscope", "exec", "python", "manage.py" ]
Important!

pyroscope exec depends on ptrace, so when running the docker container, make sure to add --cap-add=sys_ptrace to your docker run command. You can read more about this here.

In docker-compose you'll need to add the following code:

cap_add:
- SYS_PTRACE