Added support for Docker. Container can easily be started with docker compose
Description
Added support for containerization with Docker. To run webui you need to have Docker installed, clone the repository and execute docker compose up in the root directory of the repository. The first startup installs all the dependencies and subsequent startups are much quicker. The webui is exposed at localhost:7860
Checklist:
- [x] I have read contributing wiki page
- [x] I have performed a self-review of my own code
- [x] My code follows the style guidelines
- [x] My code passes tests
I'm testing this patch
(0) I've modified @ShadowCrafter011 's Dockerfile a bit as below ,
- FROM python:3.10-bookworm
+ FROM python:3.10
...
- RUN ./webui.sh --skip-torch-cuda-test --prepare-environment-only
+ RUN ./webui.sh --skip-torch-cuda-test --exit
- CMD [ "./webui.sh", "--skip-prepare-environment"]
+ CMD [ "./webui.sh", "--skip-prepare-environment" , "--listen"]
(1) Now just run container from the image logging as below, now seems ok:
docker run -p 7860:7860 $image
.....
################################################################
Launching launch.py...
################################################################
glibc version is 2.36
Check TCMalloc: libtcmalloc_minimal.so.4
./webui.sh: line 258: bc: command not found
./webui.sh: line 258: [: -eq: unary operator expected
libtcmalloc_minimal.so.4 is linked with libc.so,execute LD_PRELOAD=/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4
Launching Web UI with arguments: --skip-prepare-environment
/webui/venv/lib/python3.10/site-packages/timm/models/layers/__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
Warning: caught exception 'Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx', memory monitor disabled
Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to /webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
4%|█████▉ | 174M/3.97G [02:54<59:12, 1.15MB/
.....
Loading weights [cc6cb27103] from /webui/models/Stable-diffusion/v1-5-pruned-emaonly.ckpt
Running on local URL: http://0.0.0.0:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 9.9s (import torch: 4.7s, import gradio: 1.2s, setup paths: 0.9s, initialize shared: 0.1s, other imports: 0.6s, load scripts: 0.9s, create ui: 0.9s, gradio launch: 0.5s).
Creating model from config: /webui/configs/v1-inference.yaml
Guys, you can move on.
Hi, @ShadowCrafter011 , I've created another PR https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/16737 to push the progress , since we do need a image now :-) which we together are co-author, can you please double check ?
and @w-e-w , your comments are all addressed there.Thank you
@panpan0000 I've made some changes myself because using the webui I realised it needed volumes for configs, extensions and embeddings so that they are persisted.
@w-e-w I've pushed a commit to address the changes you requested.
There is already a docker image that have been maintained for over 1½ years. If there is anything in the main repo that causes these not to work then I understand if you request some changes to make it compatible again. But as far as I can see there is no issue with the current state of it. In fact it was updated less than 24 hours ago. universonic/stable-diffusion-webui at the docker hub
universonic/stable-diffusion-webui at the docker hub
Hi, @silveroxides amazing, glad to see that .
I found docker image's source code here , am I right ? https://github.com/universonic/docker-stable-diffusion-webui
Per my understanding for open source community best practice :
(1) I suggest that code(Dockerfile..etc) can be PR (merged) into this repo, as part of manifest of AUTOMATIC1111/stable-diffusion-webui, so that universonic's work can be adopted by more people.
Putting those Dockerfile/K8S yaml in this code repo is a common practice. : for example:
- StableSwarmUI https://github.com/Stability-AI/StableSwarmUI/blob/master/Dockerfile
- SGLang https://github.com/sgl-project/sglang/tree/main/docker
- vLLM https://github.com/vllm-project/vllm/blob/main/Dockerfile
(2) we should provide automatic Github CI Action ,auto build new docker images tag when AUTOMATIC1111/stable-diffusion-webui being released (just like https://github.com/universonic/docker-stable-diffusion-webui/tree/main/.github/workflows) ,
just like what I mention in https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/16738, the images can be more official if the image can be download in repo name as :https://hub.docker.com/r/automatic1111/stable-diffusion-webui. what do you think @w-e-w
Anybody can cover that effort ? I think people in this thread are willing to.
@panpan0000
I understand your points but if you do check the state of this repo right now where the actual maintainer only appears once in a blue moon and w-e-w is being a real champ keeping stuff afloat otherwise, then you would probably understand that it isn't just as simple as a PR. Someone will have to maintain this part and ensure that it is working properly and as stated above, we currently do not have anyone with the experience with Docker that also has at least some contribution history that are volunteering. Other than than, @w-e-w are you able to set up Github actions in this repo?
We will have to see what happens going forward, but don't count on a swift merge of this or the other PR.
are you able to set up Github actions in this repo?
anyone can create an PR for action / workflow, I believe it will work immediately after it's merged
but only AUTO can set Actions secrets and variables which would be required if you wish to do publication
note: I currently only have write access to dev branch not main
Thank you both for your explanation @w-e-w @silveroxides After checking github insight, I have just come to realize the vulnerability of community governance in this great and popular repository. It seems that this issue is not merely about basic Docker knowledge, but rather about the sustainability of maintaining this repository: a healthy community could have good governance strategies, such as hierarchical reviewers/maintainers, as well as roadmap/design proposal mechanisms, and even regular meetings or voting decision-making processes....etc
( I was "born" in the Docker/K8S world & Linux Foundation, so I get used to the open source operational models. )
Maybe @AUTOMATIC1111 can consider a bit about community governance , so that more people can help who can build trust and credit eventually.
Sorry if I made something wrong as a newbie of SD's world..
Also worth looking at https://github.com/AbdBarho/stable-diffusion-webui-docker and my fork: https://github.com/simonmcnair/stable-diffusion-webui-docker