Building an XProf Docker Image
Stay organized with collections
Save and categorize content based on your preferences.
This document describes how to build a Docker image for XProf using the official release from PyPI.
Dockerfile
Create a file named Dockerfile with the following content:
FROMpython:3.11-slim
ARGXPROF_VERSION=2.21.0
ENVPYTHONUNBUFFERED=1
WORKDIR/app
RUNpipinstall--no-cache-dirxprof==${XPROF_VERSION}
EXPOSE8791 50051
ENTRYPOINT["xprof"]
CMD["--logdir=/app/logs","--port=8791"]
How to Build
- Save the content above as
Dockerfilein an empty directory. Build the image using the following command:
dockerbuild-txprof:2.21.0.
You can change the version by modifying the XPROF_VERSION argument in the
Dockerfile or by passing --build-arg XPROF_VERSION=<version> to the docker
build command.
How to Run
Run with Local Logs
Map your local log directory to /app/logs in the container.
dockerrun-p8791:8791\
-v/tmp/xprof_logs:/app/logs\
xprof:2.21.0
Run with GCS Logs
Mount your local gcloud credentials so xprof can authenticate with Google Cloud Storage.
dockerrun-p8791:8791\
-v~/.config/gcloud:/root/.config/gcloud\
xprof:2.21.0\
--logdir=gs://your-bucket-name/xprof_logs--port=8791