Run This Ai
EN DE

Getting Started with SWE-agent: Self-Hosted Code Fixing with Docker

SWE-agent Banner

Quick Start: Run SWE-agent with Docker

SWE-agent is designed to run in Docker containers for safe, isolated code execution. The official Docker image sweagent/swe-agent:latest includes everything you need to start fixing GitHub issues autonomously.

Prerequisites

  • Docker installed on your machine (20.10+)
  • An OpenAI or Anthropic API key
  • Git installed for cloning repositories
  • Minimum 4GB RAM (8GB recommended)

Installation

Pull the official Docker image:

docker pull sweagent/swe-agent:latest

Run SWE-agent against a specific GitHub issue:

docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $PWD/config:/config \
  -e OPENAI_API_KEY=*** \
  sweagent/swe-agent:latest \
  --problem_statement "https://github.com/owner/repo/issues/123"
SWE-agent GitHub

Understanding the Output

SWE-agent generates detailed trajectories of every action it takes. You'll find patch files (unified diffs of code changes), trajectory logs (full session transcripts), and test results from any test suites the agent ran to verify its fix.

Docker Compose Setup

services:
  swe-agent:
    image: sweagent/swe-agent:latest
    restart: unless-stopped
    ports:
      - "8080:8080"
    volumes:
      - ./data/swe-agent:/data
      - /var/run/docker.sock:/var/run/docker.sock

Tips for Best Results

  • Be specific in issue descriptions: Well-described issues with reproduction steps yield much better results
  • Use the right model: GPT-4o and Claude Sonnet 4 perform best on complex bugs
  • Combine with CI: Automate SWE-agent runs on new issues via GitHub Actions

Conclusion

SWE-agent brings production-grade autonomous bug fixing to your own infrastructure. With Docker's isolation, flexible LLM support, and comprehensive trajectory tracking, it's an invaluable tool for reducing time developers spend on routine bug fixes.

#tutorial #docker #self-hosted #swe-agent #code-fixing