https://github.com/yanwenkun/sd-webui-docker-base
🐳 Dockerfile for 🖼️ Stable Diffusion WebUI, only runtime environment & bootstrapping scripts. | SD-WebUI 的容器镜像,但仅含运行环境与安装启动脚本。
https://github.com/yanwenkun/sd-webui-docker-base
automatic1111 docker stable-diffusion stable-diffusion-webui
Last synced: 10 months ago
JSON representation
🐳 Dockerfile for 🖼️ Stable Diffusion WebUI, only runtime environment & bootstrapping scripts. | SD-WebUI 的容器镜像,但仅含运行环境与安装启动脚本。
- Host: GitHub
- URL: https://github.com/yanwenkun/sd-webui-docker-base
- Owner: YanWenKun
- License: mulanpsl-2.0
- Created: 2023-03-08T16:53:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-29T07:21:16.000Z (over 1 year ago)
- Last Synced: 2025-04-06T01:32:28.152Z (about 1 year ago)
- Topics: automatic1111, docker, stable-diffusion, stable-diffusion-webui
- Language: Shell
- Homepage: https://hub.docker.com/r/yanwk/sd-webui-base
- Size: 132 KB
- Stars: 23
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
# Yet another Docker image for Stable Diffusion WebUI
image::https://github.com/YanWenKun/sd-webui-docker-base/actions/workflows/on-push.yml/badge.svg["GitHub Workflow Status"]
image::docs/chart-concept.svg["Concept Design"]
*link:README.zh.adoc[>> 中文文档 <<]*
This repo is inspired by https://github.com/AbdBarho/stable-diffusion-webui-docker[AbdBarho], with a different approach, and only supports https://github.com/AUTOMATIC1111/stable-diffusion-webui[AUTOMATIC1111].
## Idea
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.
## How it works
1. At first start, a script will download latest SD-WebUI, some extensions and essential models.
2. The whole SD-WebUI will be stored in a local folder (`./storage/stable-diffusion-webui`).
3. 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.
4. At every restart of the container, a script will update SD-WebUI & its extensions.
## Prerequisites
* NVIDIA GPU with ≥6GB VRAM (for 4GB see <>).
* Latest NVIDIA GPU Drivers, Both Game and Studio version will work.
* Docker Installed
** Windows user could use https://www.docker.com/products/docker-desktop/[Docker Desktop] with WSL2 enabled.
## Usage
.A. Using `docker compose`
[source,sh]
----
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
----
.B. Using `docker run`
[source,sh]
----
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/
// ## (Deprecated) link:nightly/README.adoc[Nightly Build]
// For image tag `nightly`:
// * It builds more frequently.
// * It's ready for https://github.com/d8ahazard/sd_dreambooth_extension[DreamBooth Extension].
// * It come with dev version of xFormers.
// ** (Don't expect performance boost, the stable version is good enough now.)
// link:nightly/README.adoc[Read more about using nightly].
// The base `latest` will keep simple and easy for people to modify.
[[q-n-a]]
## Q & A
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!
1. In `docker-compose.yml`, delete `deploy:` section.
** Or in `docker run`, delete `--gpus all`.
2. In `CLI_ARGS`, change `--xformers --medvram` to
`--use-cpu all --no-half --precision full`.
More `CLI_ARGS` available at https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings[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.
## Some commands for debugging
.Build the image, print all logs to STDOUT.
[source,sh]
----
docker build . -f Dockerfile -t yanwk/sd-webui-base --progress=plain
----
.Run a one-time container
[source,sh]
----
docker run -it --rm --gpus all -p 7860:7860 \
-v "$(pwd)"/storage:/home/runner \
--env CLI_ARGS="--xformers --medvram" \
yanwk/sd-webui-base
----
.Run into a root bash
[source,sh]
----
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
----
.Run a rootless container (Podman)
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.
[source,sh]
----
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
----
## Special Thanks
Thank again for https://github.com/AbdBarho/stable-diffusion-webui-docker[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.
## License
link:LICENSE[Mulan Permissive Software License,Version 2]
This open source license is written and valid both in Chinese and English, how good is that!