Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Docker. Container can easily be started with docker compose #16688

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
models
models/
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.10-bookworm

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just python:3.10 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe another alternative is nvcr.io/nvidia/pytorch:24.12-py3 which torch and cuda embeded.


WORKDIR /webui

RUN apt-get update && \
apt-get install ffmpeg libsm6 libxext6 dos2unix google-perftools -y

COPY . .

RUN dos2unix ./webui.sh ./webui-user.sh

RUN groupadd --system --gid 1000 webui && \
useradd webui --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
chown -R webui:webui .
USER 1000:1000

RUN ./webui.sh --exit --skip-torch-cuda-test

CMD [ "./webui.sh", "--skip-prepare-environment", "--listen" ]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ Alternatively, use online services (like Google Colab):

- [List of Online Services](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Online-Services)

### Running with Docker

DISCLAIMER: This currently only works with NVIDIA GPUs

You need to have [Docker](https://www.docker.com/) installed on your system. Then clone this repository and execute `docker compose up` in the root of the repository. The first time you execute this command will take a long time as all the dependencies are installed. Subsequent runs of the command should start up the webui pretty much instantly. To stop the webui press CTRL+C and wait a few seconds.

Models are provided to the Docker container using a bind mount. This means that if you add a new model to the models directory it should be available in the webui after a checkpoint refresh without needing to rebuild or restart the container.

The server will be accessible at [localhost:7860](localhost:7860)

### Installation on Windows 10/11 with NVidia-GPUs using release package
1. Download `sd.webui.zip` from [v1.0.0-pre](https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.0.0-pre) and extract its contents.
2. Run `update.bat`.
Expand Down
28 changes: 28 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:
webui:
build: .
volumes:
- type: bind
source: ./models
target: /webui/models
- type: bind
source: ./outputs
target: /webui/outputs
- type: bind
source: ./extensions
target: /webui/extensions
- type: bind
source: ./embeddings
target: /webui/embeddings
- type: bind
source: ./configs
Copy link

@panpan0000 panpan0000 Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there're already several yaml files under configs folder, did you mean user can customize their own config to override the default ones ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've gathered that's where the customizations made in the webui are persisted

target: /webui/configs
ports:
- 7860:7860
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
Loading