Skip to content

Repository files navigation

Build CUDA Torch xFormers A1111 License

🧠 a1111-docker

A reproducible, persistent Docker setup for running AUTOMATIC1111's Stable Diffusion WebUI with GPU acceleration, extension support, and clean config management.

Everything the WebUI needs — Python environment, requirements, and the sub-repositories A1111 depends on — is baked into the image at build time, pinned to a known-good release. First launch needs no network access and no surprise downloads.


📖 Need to install Docker or the NVIDIA Container Toolkit?
See the HOWTO guide for step-by-step instructions for Ubuntu/Debian, Fedora, Arch, and WSL.

📘 New to Docker or AUTOMATIC1111 in general?
Check out the GETTING_STARTED.md guide for a plain-language introduction: what Docker is, what A1111 does, what's persistent vs. ephemeral in this build, and how to add your first models.


🐧 Setup for Linux

Prerequisites: Docker Engine, Docker Compose plugin, and the NVIDIA Container Toolkit must be installed. If you need help setting these up, see the HOWTO guide.

git clone https://github.com/tsondo/a1111-docker.git ~/a1111-docker
cd ~/a1111-docker
bash setup.sh --pull

That's it. setup.sh creates the persistent folders and config files, pulls the prebuilt image (about a 7 GB download), and starts the container. Access the WebUI at http://localhost:7860

Prefer to build the image yourself? Run bash setup.sh without --pull — see Building locally below.

A .env file is optional — the defaults work out of the box. Copy .env.sample to .env if you want to customize where models, outputs, etc. are stored.


🪟 Setup for Windows (Docker Desktop + WSL2)

Prerequisites: Docker Desktop with WSL2 integration and the NVIDIA Container Toolkit. See the HOWTO guide for full setup steps.

Once Docker is working inside your WSL terminal:

git clone https://github.com/tsondo/a1111-docker.git ~/a1111-docker
cd ~/a1111-docker
bash setup.sh --pull

Access the WebUI at http://localhost:7860 from your Windows browser.

Important: Run all commands inside WSL -- not PowerShell or CMD. Keep the folder inside the Linux filesystem (~/a1111-docker), not under /mnt/c/, for much better performance.


🔴 AMD GPUs (ROCm) — experimental

The same two commands work on AMD: setup.sh auto-detects an AMD GPU (via /dev/kfd) and uses the ROCm image (ghcr.io/tsondo/a1111-docker:latest-rocm) automatically. Requirements are simpler than NVIDIA's — just native Linux with the standard amdgpu kernel driver (included in every modern distro). No container toolkit needed. ROCm is not supported under WSL2 — Linux only.

Two AMD-specific notes:

  • xformers is CUDA-only, so the ROCm variant uses PyTorch's built-in SDP attention instead. This happens automatically.
  • Many consumer cards need a compatibility override before generation works. If the container starts but generating images fails or crashes, copy .env.sample to .env and uncomment HSA_OVERRIDE_GFX_VERSION: use 10.3.0 for RX 6000-series cards, 11.0.0 for RX 7000-series. Then restart.

This variant is untested on real hardware so far — if you run it, success or failure reports are very welcome as GitHub issues.


📦 The prebuilt image

A ready-to-run image is published to GitHub Container Registry as ghcr.io/tsondo/a1111-docker, built by CI from this repo with A1111 pinned to a known-good release. bash setup.sh --pull uses it automatically. If the pull fails (e.g. no network to GHCR), the script falls back to building locally.


🔨 Building locally

Running bash setup.sh without --pull builds the same image on your machine instead. This downloads several GB of CUDA wheels and takes a while, but is useful if you want to modify the Dockerfile or pin a different A1111 version.


🚀 What setup.sh does

  • Creates persistent folders for models, outputs, extensions, etc.
  • Prepopulates empty config files if missing
  • Records your user/group ID so files created by the container are owned by you
  • Migrates settings from older versions of this project
  • Builds (or pulls, with --pull) the image and starts the container

Flags: --pull (use prebuilt image), --no-cache (full rebuild), -d/--detach (run in background), --rocm/--nvidia (force a GPU variant), -h (help).


🧱 Persistent Folders

These folders are mounted into the container and survive restarts and rebuilds:

Host Folder Container Path Purpose
models/ /workspace/stable-diffusion-webui/models Base models and checkpoints
outputs/ /workspace/stable-diffusion-webui/outputs Generated images
extensions/ /workspace/stable-diffusion-webui/extensions Installed extensions
embeddings/ /workspace/stable-diffusion-webui/embeddings Textual inversion embeddings
logs/ /workspace/stable-diffusion-webui/logs Runtime logs
cache/ /workspace/stable-diffusion-webui/cache HuggingFace and UI cache
pip-cache/ /workspace/stable-diffusion-webui/pip-cache Pip download cache

UI state is persisted as individual files in the repo root: config.json, ui-config.json, and styles.csv.

Everything else — the Python environment, A1111 itself, and its sub-repositories — lives inside the image. Rebuilding or updating the image never touches your persistent data.


🧩 Extension Persistence

Any extensions installed via the WebUI (e.g., ADetailer) will persist across restarts. They are stored in the extensions/ folder and mounted into the container. Their Python dependencies install into the container on first start after a rebuild; the mounted pip-cache/ keeps that fast.


📌 Version pinning

The image builds AUTOMATIC1111 at a pinned release (v1.10.1) rather than whatever master happens to be that day, so builds are reproducible. To try a different release:

docker compose build --build-arg A1111_VERSION=v1.10.0

or edit A1111_VERSION in the Dockerfile.

Note: Stability-AI deleted their original stablediffusion repository from GitHub, which broke older versions of this project (and stock A1111 installs). The image now clones a fork that preserves the exact commit A1111 expects.


📦 Preloading Models (Optional)

To pre-load model downloads before first launch:

mkdir -p ~/a1111-docker/models/Stable-diffusion
wget -O ~/a1111-docker/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors

🔁 Daily Usage

Start:

docker compose up -d

Stop:

docker compose down

Watch logs:

docker compose logs -f

Running bash setup.sh again is always safe — it re-verifies folders and configs before starting.


⬆️ Updating

cd ~/a1111-docker
git pull
bash setup.sh --pull

This picks up the latest published image (or, without --pull, rebuilds only the layers that changed). Your models, outputs, and settings are untouched.

If you're troubleshooting a broken build, force a clean one:

bash setup.sh --no-cache

About

Dockerized Stable Diffusion WebUI (AUTOMATIC1111) with persistent config, extension support, and full compatibility up to NVIDIA 5090 GPUs.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages