Skip to main content
It’s Thursday morning. With the week’s crises resolved, Sarah finally has time to work proactively. Instead of fighting fires, she reviews the backlog and the technical debt that slows the team down. Two items jump out: a massive 2 GB Docker image that’s slow and expensive to store and move, and a long-overdue effort to harden the infrastructure’s security posture.
A close-up screenshot of a projects sidebar in a task-tracking app showing work items such as "Issue 1 (Technical Debt): Optimize 'payment-service' Docker Image (Size: 2.1 GB)" and "Issue 2 (Security Backlog)". A search/new work item field and navigation icons for Projects and Wiki are also visible.
To automate recurring expert tasks, Sarah creates subagents — lightweight, single-purpose AI assistants inside Qwen. Each subagent encapsulates a repeatable workflow: analyze, fix, and report. Her first two subagents are:
  • Docker Optimizer — reduces image size and improves runtime security.
  • Terraform Security Expert — scans Terraform for insecure patterns and generates fixes (using Checkov).

Docker Optimizer subagent

This subagent encodes Docker best practices (multi-stage builds, minimizing layers, using slim base images, non-root runtime) and automates the full optimize-build-verify loop.
This agent automates the common tasks a Docker expert would perform manually: convert single-stage builds to multi-stage, reduce the runtime footprint, add .dockerignore, and ensure the container runs as a non-root user.

Terraform Security Expert subagent

Sarah’s second subagent focuses on infrastructure-as-code hardening. It runs static analysis across Terraform code, surfaces critical issues (public security groups, missing encryption, overly permissive IAM policies) and produces remediation snippets.

Quick tips for using subagents

Getting started tips:
  1. Ask precise questions or provide specific file paths for best results.
  2. Edit files, run commands, or request reports interactively.
  3. Add QWEN.md files to customize how an agent handles a repository.
  4. Use /help inside the interactive mode for guidance.

Managing and running agents

Sarah verifies her virtual DevOps team is online using the built-in agents manager:
Example simplified output:
Instead of hand-editing a Dockerfile, Sarah describes the optimization in plain English and asks Qwen to delegate it to the Docker Optimizer subagent:
The subagent coordinates reading files, making changes, and running builds. Example (trimmed and cleaned for clarity):
Everything runs automatically: the Docker Optimizer reads the source Dockerfile, writes Dockerfile.optimized, adds a .dockerignore, builds the optimized image, and validates the result.

Typical results after optimization

After rebuilding, you might see a much smaller image:
Key changes the Docker Optimizer typically applies:
  • Convert a single-stage Dockerfile into a multi-stage build to keep only runtime artifacts in the final image.
  • Use a smaller base image when safe (e.g., python:3.12-slim) to reduce surface area and size.
  • Add a .dockerignore to exclude unnecessary files from build context.
  • Remove build-time tools and dev dependencies from the final image.
  • Ensure the final container runs as a non-root user and only installs required runtime packages.
Result: the image drops from ~2 GB to ~300 MB (~85% reduction), which lowers registry costs and speeds deployments.

Try this locally

Example prompts to invoke agents:
After execution, Qwen shows which agents ran and returns updated files, build logs, and any remediation reports.

Agents at a glance

Start building your own virtual DevOps team. In this lesson you’ll create the Docker Optimizer and Terraform Security subagents from scratch and let them analyze a bloated image and insecure IaC — so the team no longer has to be the only experts.

Watch Video

Practice Lab