# AI with hardened container images

URL: https://chainguard-docs-preview-git-1016-404s.chainguard.app/software-security/learning-labs/ll202507.md
Last Modified: September 28, 2026
Tags: Learning Labs, Chainguard Containers, AI

Learning Lab for July 2025 on securing AI workloads with hardened container images


The July 2025 Learning Lab with Patrick Smyth covers AI with Hardened Container Images. In this session, learn how to secure AI workloads by reducing vulnerabilities in container images by over 90%. Patrick demonstrates hands-on techniques for training an animal detection model using PyTorch with hardened container images, creating minimal and secure deployments, and running AI frameworks with zero CVEs.

[Watch the video on YouTube](https://www.youtube.com/watch?v=JGSc6BwjbRI)


## Sections

- [0:00](https://www.youtube.com/watch?v=JGSc6BwjbRI) Introduction and updates
- [2:02](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=122s) Preparation: Docker pull instructions for demo
- [3:39](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=219s) Chainguard! Who are we?
- [4:34](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=274s) CVE system fundamentals
- [6:48](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=408s) "Boss assigned me to fix Ubuntu" problem
- [7:41](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=461s) Introduction to Chainguard Containers
- [8:54](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=534s) Zero CVE containers: Real results and comparisons
- [11:10](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=670s) How we achieve zero CVEs: Minimal, Fresh, Advisory, Patch
- [13:24](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=804s) AI container challenges: Size and complexity
- [14:59](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=899s) PyTorch container analysis: CVEs, packages, and executables
- [16:21](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=981s) Demo introduction: Image classification with PyTorch
- [17:59](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=1079s) Demo walkthrough and repository overview
- [19:28](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=1168s) Demo: Running the training command
- [22:01](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=1321s) Demo: Downloading test image and running inference
- [23:20](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=1400s) Recent developments in Chainguard AI containers
- [25:09](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=1509s) Other AI containers: TensorFlow, KServe, Triton backends
- [26:46](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=1606s) Q&A
- [35:18](https://www.youtube.com/watch?v=JGSc6BwjbRI&t=2118s) Chainguard AI course and additional resources

## Demo

In the demo, Patrick trains and runs inference on an image classification model using PyTorch and Chainguard's hardened container image. The model classifies images of octopuses, whales, and penguins, demonstrating how to work with AI workloads securely.

[Demo repository: PyTorch getting started](https://github.com/chainguard-dev/pytorch-getting-started/blob/main/learning-lab.md)

### Training the model

First, create a directory for the project and download the necessary files:

```bash
mkdir -p ~/image_classification && cd ~/image_classification && \
curl https://codeload.github.com/chainguard-dev/pytorch-getting-started/tar.gz/main | \
tar -xz --strip=1 pytorch-getting-started-main/
```

Then run the training script inside a Chainguard PyTorch container:

```bash
docker run --user root --rm -it \
  --platform linux/amd64 \
  -v "$PWD/:/home/nonroot/octopus-detector" \
  cgr.dev/chainguard/pytorch:latest \
  "/home/nonroot/octopus-detector/image_classification.py"
```

This command generates a model file named `octopus_whale_penguin_model.pt`.

### Running inference

To test the trained model, first download a test image:

```bash
curl https://raw.githubusercontent.com/chainguard-dev/pytorch-getting-started/main/inference-images/octopus.jpg > ~/image_classification/octopus.jpg
```

Then run the classification:

```bash
cd ~/image_classification && \
docker run --user root --rm -it \
  --platform linux/amd64 \
  -v "$PWD:/home/nonroot/octopus-detector" \
  cgr.dev/chainguard/pytorch:latest \
  "/home/nonroot/octopus-detector/image_classification.py" \
  "/home/nonroot/octopus-detector/octopus.jpg"
```

The demo showcases how Chainguard's hardened PyTorch image provides the same functionality as traditional images while eliminating vulnerabilities and reducing the attack surface.

## Resources

- [Slide deck](/downloads/learning-lab-ai-images.pdf)
- [Demo repository](https://github.com/chainguard-dev/pytorch-getting-started)
- [Chainguard AI/ML Supply Chain Security Course](https://courses.chainguard.dev/securing-ai)
- [Getting started with the PyTorch Chainguard Container](https://edu.chainguard.dev/chainguard/containers/getting-started/ai-and-data/pytorch/)
- [PyTorch container overview](https://images.chainguard.dev/directory/image/pytorch/overview)
- [Beyond Zero: Eliminating Vulnerabilities in PyTorch Container Images (PyTorch 2024)](https://www.youtube.com/watch?v=1klynk1dxYA)

