This repo is inspired by AbdBarho, with a different approach, and only supports AUTOMATIC1111.
A heavy user of SD-WebUI would probably have a lot of models, extensions, and want everything up-to-date. This Docker image is how I figured out to manage them:
Keeping the app & data in one place, and leaving the dependency in Docker.
-
At first start, a script will download latest SD-WebUI, some extensions and essential models.
-
The whole SD-WebUI will be stored in a local folder (
./storage/stable-diffusion-webui
). -
If you already have a SD-WebUI bundle, put it there and make an empty file (
./storage/.sdw-download-complete
) so the start script will skip downloading. -
At every restart of the container, a script will update SD-WebUI & its extensions.
-
NVIDIA GPU with ≥6GB VRAM (for 4GB see Q & A).
-
Latest NVIDIA GPU Drivers, Both Game and Studio version will work.
-
Docker Installed
-
Windows user could use Docker Desktop with WSL2 enabled.
-
docker compose
git clone https://github.com/YanWenKun/sd-webui-docker-base.git
cd sd-webui-docker-base
docker compose up --detach
# Update image (only when Python components is outdated)
git pull
docker compose pull
docker compose up --detach --remove-orphans
docker image prune
docker run
mkdir -p storage
docker run -it \
--name sd-webui \
--gpus all \
-p 7860:7860 \
-v "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="--xformers --medvram --allow-code --api --enable-insecure-extension-access" \
yanwk/sd-webui-base
# Update image (only when Python components is outdated)
docker rm sd-webui
docker pull yanwk/sd-webui-base
# Then re-run 'docker run' above again
Once the app is loaded, visit http://localhost:7860/
Q: My GPU only has 4GB VRAM
A: Modify args in CLI_ARGS
, change --medvram
to --lowvram
.
Q: Can I run it without a NVIDIA GPU?
A: Use CPU!
-
In
docker-compose.yml
, deletedeploy:
section.-
Or in
docker run
, delete--gpus all
.
-
-
In
CLI_ARGS
, change--xformers --medvram
to--use-cpu all --no-half --precision full
.
More CLI_ARGS
available at SD-WebUI Wiki.
Q: Why are you using latest version of dependencies?
A: Try to squeeze more performance out of GPUs (using latest stable version of PyTorch & xFormers).
Q: Will upstream changes break this image?
A: Probably will with major changes in launch.py
& requirements_versions.txt
, otherwise unlikely. User’s data will always stay safe. User just need to update Docker image after I update this repo.
docker build . -f Dockerfile -t yanwk/sd-webui-base --progress=plain
docker run -it --rm --gpus all -p 7860:7860 \
-v "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="--xformers --medvram" \
yanwk/sd-webui-base
docker run -it --rm --gpus all \
-v "$(pwd)"/storage:/home/runner \
-p 7860:7860 \
--user root \
-e CLI_ARGS="--xformers --medvram --allow-code --api --enable-insecure-extension-access --ckpt ./test/test_files/empty.pt" \
yanwk/sd-webui-base:latest /bin/bash
Inside the pod, Podman will mount volume as root, scripts will run as root. And from the host side, we see files keep their original ownership.
mkdir -p storage
podman pull docker.io/yanwk/sd-webui-base:latest
podman run -it --rm \
--name sd-webui-rootless \
--device nvidia.com/gpu=all \
--security-opt label=disable \
-p 7860:7860 \
-v "$(pwd)"/storage:/root \
--user root \
--workdir /root \
-e CLI_ARGS="--xformers --medvram --allow-code --api --enable-insecure-extension-access" \
yanwk/sd-webui-base:latest \
/bin/bash /home/scripts/root-wrapper.sh
Thank again for AbdBarho's devotion and brilliant works, which my inspiration emerged from. I would definitely consider webui-docker
if I want to deploy multiple WebUIs and only one set of models.
This open source license is written and valid both in Chinese and English, how good is that!