Running PyRIT and CoPyRIT in Docker

PyRIT's Docker Compose setup gives a red teaming team a ready-made JupyterLab workstation with PyRIT installed. This page explains what it provides, when to use it, how host configuration and GPU support fit in, and what to confirm before relying on it.

On this page

Running PyRIT and CoPyRIT in Docker: when a container is the right starting point

A team that needs a repeatable PyRIT environment, without hand-building Python dependencies on every workstation, is the reader this section serves. The Docker Compose setup provides a container with PyRIT and its dependencies pre-installed, JupyterLab served at ` and CPU mode by default, with optional GPU support. The container is based on the Microsoft Azure ML Python 3.12 inference image, so the Python version inside it is set by that image rather than by your host. Check the PyRIT docker README for the exact image and Compose settings in the release you plan to use.

The choice comes down to where you want the environment to live. A pip install puts PyRIT into a Python environment you manage, which suits engineers who already maintain Python tooling and want PyRIT inside their own projects. The container suits a red teamer or a small group who want the same notebooks, libraries and versions on each machine with little setup. Running CoPyRIT as a shared service is a different pattern entirely: it serves several people from one backend with access control, and it is not what this Compose file provides. The Docker setup is a workstation pattern, not a hosted deployment. It binds JupyterLab to the local machine, and nothing in it makes the environment safe to expose to a network.

Before you adopt the container, confirm three things with your own environment in mind: which PyRIT release your team will pin, whether your hosts can run Docker under your endorsed configuration, and whether anyone needs GPU acceleration on the host. Decide who owns the container image and its updates, since the image carries dependencies that will need refreshing as PyRIT releases change. If the team later needs shared access, plan for a separate CoPyRIT deployment instead of extending a workstation container to serve others.

Docker options compared: CPU, GPU, host configuration and where each fits

This table compares the default CPU container, the optional GPU mode, the Compose setup and a manual Docker run, and the base image they share. Read each row against your team size and where the instance will sit, and treat the last column as the point where a managed deployment should be considered.

OptionWhat it gives youBest fit and when to move to managed
Default CPU modePyRIT and its dependencies pre-installed, with JupyterLab served at localhost:8888 on the hostFits a single red teamer on a workstation. Move to a managed deployment if several people need the same instance or access must be gated by identity.
Optional GPU modeSame container with GPU support enabled for workloads that use local models on the hostFits a red teamer who runs local models and has a GPU-equipped host. Confirm driver and container runtime support for your hardware before you plan around it.
Docker Compose setupCreates ~/.pyrit/.env on the host and mounts it into the container automaticallyFits a single user who wants the least configuration to start. Keep the port bound to localhost unless you have a reviewed access control in front of it.
Manual Docker runFull control over mounts, ports, environment variables and image tagFits teams with container experience who need custom mounts or a specific runtime. Each mount of host secrets is a manual step to review and repeat.
Azure ML Python 3.12 base imageInherited base image on which the PyRIT container is builtFits anyone who needs a known Python 3.12 environment. Note that the PyRIT documentation recommends Python 3.13, so check which interpreter your scripts expect.
Host secrets fileCredentials and settings kept in ~/.pyrit/ on the host, mounted read-write into the containerFits a single operator. For shared use, move secrets to a managed store and confirm who can read the host directory.
Shared team workstationOne container serving several people through a host reachable on the networkNot recommended without identity controls. A shared JupyterLab gives every user the same credentials, so move to a managed CoPyRIT deployment with group-based access.

How to start the PyRIT Docker workstation

This sequence takes you from the v1.1.0 Docker files to a running JupyterLab workspace where PyRIT imports cleanly, with credentials held in a host file that the container reads. Each step ends with a check so you know whether to continue or fix the problem first.

  1. Obtain the v1.1.0 Docker files

    Get the Docker setup from the PyRIT repository at the v1.1.0 tag, so the Compose file and image definition match the release you plan to run. Your platform or security engineer does this on a workstation with Docker installed. You know it is done when the docker directory contains a README and a Compose file, and the README describes the JupyterLab port and CPU default. If you are standardizing on a later release, confirm the tag and file layout with the project first.

  2. Let Compose create the host secrets file

    Run the Compose setup from the docker directory so it creates the credentials file on the host at ~/.pyrit/.env and mounts it into the container automatically. Nothing needs to be mounted by hand for this file. You know it worked when the file exists on the host under your home directory and is readable only by the account that runs Docker. If the file is missing after startup, check the Compose output before continuing.

  3. Add model and target credentials

    Edit ~/.pyrit/.env on the host and add the keys for the model and target endpoints you intend to test, such as Azure OpenAI or other providers your scope covers. Store only what the session needs, and keep the file out of version control and shared drives. You know this step is done when the variables are present and the file is saved, and you have confirmed the names against the PyRIT secrets documentation for your release. Do not paste keys into notebooks.

  4. Start the container with Compose

    Bring the stack up with Docker Compose in CPU mode, which is the default. The container includes PyRIT and its dependencies, so no local Python environment is needed. You know it is running when Compose reports the service as started and docker ps lists the container as up. If the container exits, read its logs first, since missing or malformed credentials and port conflicts are the usual causes.

  5. Open JupyterLab at localhost:8888

    In a browser on the same host, open to reach JupyterLab. Use the access method the container prints at startup if the interface asks for a token. You know this step is done when a JupyterLab workspace loads and you can create or open a notebook. Keep this port bound to the local machine. Do not publish it to a wider network unless your own review has approved that exposure.

  6. Confirm PyRIT imports in a notebook

    In a new notebook inside JupyterLab, run a short import of the pyrit package and print its version. This confirms the dependencies resolved inside the image and that the container can see the mounted configuration. You know it worked when the import completes without errors and the version matches v1.1.0. If the import fails, check the image build log and the dependency versions before running any attack code.

  7. Confirm GPU enablement on a GPU host only

    Enable GPU support only on a host with working GPU drivers and container GPU access configured, following the GPU option in the Docker README. Run the same import and a simple device check from the notebook to confirm the GPU is visible to the container. You know this step is done when the device check reports the GPU. If it does not, stay in CPU mode, since the default configuration does not depend on a GPU.

How host configuration reaches the container

With the Docker Compose setup, the ~/.pyrit/.env file is created on the host and mounted into the container automatically, so the container reads the same credentials file you would use for a local PyRIT install. The settings file .pyrit_conf is read from the same ~/.pyrit/ directory, which means a single host folder holds both the secrets and the behavior settings that PyRIT uses. Before the first run, confirm that the folder exists where you expect it on your workstation or build host, because the mount follows the host path and a missing or wrong location will leave the container without the values it needs.

Keeping secrets on the host rather than in the image is the main reason for this design. An image can be copied, pushed to a registry, or shared with a team, and anything baked into it, including API keys for model targets, travels with it. Mounting the file at run time means the image stays generic and each red teamer supplies their own credentials. Treat the host .env file as a credential store: restrict it to your own user, avoid committing it to a repository, and check that it is excluded from any shared build context. Set the file to owner-only read and write (for example, chmod 600 ~/.pyrit/.env on Linux or macOS) and review the permissions after any tool or script rewrites it.

The Docker README is the authority for the mount paths and the configuration files that the container reads in the version you run. Check which files it mounts, whether .pyrit_conf is included by default, and whether any additional paths such as result or memory folders must be mapped for your data to persist. Do this against the README for the exact PyRIT release you deploy, since mount behavior can change between versions. Record the mount list in your team runbook so that a later upgrade does not silently drop a setting or write results to a container layer that is removed when the container stops.

How the host, container and JupyterLab fit together

The flow starts on the host, where ~/.pyrit/.env and ~/.pyrit_conf live in your home directory. Compose creates ~/.pyrit/.env on the host and mounts it into the container automatically, so secrets stay outside the image. Inside the container, PyRIT and its dependencies run behind JupyterLab on port 8888, and that is where your red teaming notebooks execute. Check two boundaries before you begin: who can reach port 8888 on your network, and which external AI targets the container is allowed to call with the credentials it holds.

Host config flows into the container, which calls external AI targets across a trust boundary.

Security risks of a local Docker red teaming workstation

A PyRIT container is convenient because it bundles tools, JupyterLab and secrets in one place, and that convenience concentrates risk. The cards below cover the exposure, credential, data, supply chain and maintenance issues a team should check before running the workstation beyond a single person's laptop.

Port 8888 exposed beyond the workstation

JupyterLab listens on port 8888 at by default. Any port mapping that binds to all interfaces, or a firewall rule that opens the port, lets other machines on the network reach a notebook environment that can call your AI targets. Check the Compose port binding and confirm that the host firewall blocks inbound access to 8888 unless you have deliberately put the service behind an access control layer.

Secrets in the mounted .env file

With the Compose setup, the ~/.pyrit/.env file on the host is mounted into the container automatically. That file usually holds API keys for every model endpoint you test, so anyone who can read the container filesystem, the host home directory or the mount can use those keys. Restrict file permissions on the host, use keys scoped to test environments, and rotate them when a team member leaves.

Populating Secrets

Shared host access to red team output

PyRIT memory stores conversations and results in SQLite by default, and those records include the adversarial prompts and model responses your team produced. On a shared host, other local users or processes can read the database files in the mounted or host directory. Decide who owns the output, set directory permissions to match, and avoid placing findings on a machine that others can access.

Pulling images without verifying source and version

A container image that you pull without checking its source can contain code you did not review, and a tag that is not pinned can change between pulls. Build from the project's own docker directory at a known release tag, record the image digest, and compare it with what the team approved. Ask the platform owner to confirm where images are stored and who can push to that registry.

Keeping the container current with releases

PyRIT ships new releases, and v1.1.0 was released on 4 September 2026. A workstation image built months earlier keeps older dependencies and may lack fixes that matter for your scanning and memory handling. Set a rebuild schedule, watch the GitHub releases page, and record which version each red team engagement used so results can be reproduced.

PyRIT releases

Reporting vulnerabilities privately

If your testing finds a flaw in PyRIT itself, report it privately through the Microsoft Security Response Center under the project's security policy rather than opening a public issue. Keep proof-of-concept details out of shared channels until the maintainers have responded. Name an owner on your team who knows this route before the first engagement starts.

Questions teams ask before running PyRIT in Docker

Can our team set up PyRIT in Docker without outside help?

Yes, most teams with a working Docker and Python background can run the Compose setup themselves, and the container ships with PyRIT and its dependencies pre-installed. The skills that matter are Docker Compose basics, handling a .env file with API keys safely, and enough Python to write or adapt attack code in JupyterLab. Ownership gets harder once the workstation must follow your change control, image patching, access rules and evidence requirements. Those are the points where a partner is often asked to help, and the internal team should decide early who owns the image, the mounted configuration and each target connection.

What makes the Docker setup take more or less effort?

Three things drive most of the effort: GPU support, credential handling and target connectivity. The container defaults to CPU mode and can be configured for GPU support, which depends on host drivers and container runtime setup on your hardware. With Docker Compose, ~/.pyrit/.env is created on the host and mounted into the container automatically, so the main decision is how that file is protected on shared workstations. Connectivity effort grows with each target, especially private endpoints, custom HTTP or WebSocket apps and web chat UIs that need a browser driver. Confirm each of these against your own environment before estimating the work.

Does a local Docker workstation replace CoPyRIT on Azure Container Apps?

No, the workstation and the Azure deployment solve different problems. A Docker workstation suits a single red teamer who runs JupyterLab and CLI work on their own machine. CoPyRIT on Azure Container Apps is the shared, web-based deployment for human-led red teaming with team access, and it has its own identity, database, network and exposure choices. Teams often use both: the container for scripting and experiments, and the shared instance for collaborative campaigns. Keep local results separate from shared memory unless you have decided how records will be exported and reviewed.

How do upgrades affect a PyRIT Docker container?

Upgrading means moving to a newer image or rebuilding with a newer PyRIT release, so the container's dependencies change with it. PyRIT's breaking releases have changed APIs before, so test your notebooks and scripts against the new version in a copy before replacing the working container. Check the release notes for the version you are moving to, and keep the mounted ~/.pyrit/.pyrit_conf and .env files under version control or backup so configuration survives rebuilds. Also confirm which base image the release uses, since the container is built on a Microsoft Azure ML Python 3.12 inference image.

What would a partner scope and quote from our written requirements?

A partner would scope the work from written requirements: which PyRIT targets must be reachable, whether GPU hardware is needed, how secrets are stored and who may use the workstation, what has to be documented, and whether the setup must be repeatable across several machines. The quote follows from that written scope, and DeployOpen does not publish a price list. Ask for the deliverables, the environments covered, the testing or handover steps, and what is excluded, such as model hosting or work outside the workstation. Fixed-scope engagements are agreed in writing before work starts.

What should we confirm about Python version support before installing?

Confirm the Python version the PyPI package supports and the version the documentation recommends, because they are not the same statement. The PyPI package supports Python 3.10 up to but not including 3.15, while the PyRIT documentation recommends Python 3.13. The Docker image has its own Python runtime, so check which version is inside the container before writing code against it. If you install PyRIT on the host as well, pin the Python version used on every machine so notebooks behave the same way. Verify these points against the current release documentation and your own environment.

Limits to confirm in your environment before you rely on the container

The Docker setup gives one person a ready-made PyRIT workstation, but several of its assumptions depend on your hardware, your base image and how many people will use it. Confirm each item below against the release you intend to run, and record the answers with your red teaming plan.

GPU drivers and runtime versions

GPU support is optional, and the container defaults to CPU mode. Before enabling GPU use, confirm which host GPU driver and container runtime versions the image expects for your release. Check this against the image's own README at the tag you pull, not against an older guide. A mismatch often shows up only when a model is first loaded, so test a small GPU job before you plan longer runs.

Docker README

Base image and Python version

The container is built on a Microsoft Azure ML Python 3.12 inference image. PyPI supports Python 3.10 up to but not including 3.15, and the documentation recommends Python 3.13. Confirm the Python version inside the running container and decide whether a 3.12 base is acceptable for your team's policy. If you build your own image, record the base image tag and Python version so the next upgrade is reproducible.

Single-workstation access model

This pattern is built for one red teamer on one machine. JupyterLab on port 8888 has no team sign-in layer described in the supplied materials, so do not expose it to a network where other users can reach it. If several people need the same results, use a shared server with access control instead. Confirm how the container's JupyterLab authentication is configured in your release before any network binding.

Memory and storage for SQLite

PyRIT memory stores conversations and results in SQLite by default, so the database grows with every run and lives in the container's storage path unless you mount it. Estimate run volume with your own test plan, then size disk space and back up the database file. Confirm where the database is written in your release and whether it survives a container rebuild.

PyRIT documentation

Mount paths for each release

The host file ~/.pyrit/.env is mounted into the container automatically with Docker Compose, and PyRIT also reads ~/.pyrit/.pyrit_conf. Mount paths, file names and the container user's home directory can change between releases. Confirm the exact paths for the version you run by reading that release's Compose file and secrets documentation, then check that credentials are not baked into the image.

Populating secrets

When a shared CoPyRIT deployment should replace the workstation container

A shared CoPyRIT deployment should replace the workstation container once more than one person needs the same red teaming results, the same targets and the same memory, or once someone outside your local machine needs to run attacks. The Docker setup gives a single user a JupyterLab workstation on localhost:8888 with ~/.pyrit/.env mounted from the host. That arrangement keeps credentials and conversation records on one machine, which is fine for one tester but becomes a risk when several people, or a security review, depend on that data. The trigger is usually a question you cannot answer cleanly: who ran which attack, where the memory lives, and who can see it.

Shared access needs three controls that the workstation container does not provide. First, identity: CoPyRIT access should be gated by Entra ID group membership, with a separate admin group for configuration routes, so that only approved red teamers can run attacks and only designated staff can change settings. Second, isolation: when red teams, product groups or partners have different targets, data or approval chains, each usually needs its own CoPyRIT instance with separate database, secrets, app registration and network. Third, network exposure: a shared server needs Azure-hosted network controls such as a managed identity, private networking and a deliberate ingress path. Before you move, confirm which of these your organization requires and who owns each decision.

Treat the sibling topics as the next steps, each covering one of these controls. Running CoPyRIT locally for a single red teamer explains what local mode disables and why a local server must not be exposed to the network. Deploying CoPyRIT on Azure Container Apps describes the Bicep deployment, its network and identity components and the choices that affect exposure. Controlling CoPyRIT access with Entra ID groups covers the tenant, client and group settings and the Graph permission the backend needs. Deploying separate CoPyRIT instances for each team covers deploy_instance.py and the Azure permissions it requires. Confirm each of these against the current release notes before you plan the change.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.