mirror of
https://github.com/sd-webui/stable-diffusion-webui.git
synced 2024-12-13 18:02:31 +03:00
Streamline Docker Quickstart Experience (#1261)
* Cleaned up Docker documentation and process * Added back `build` section to Dockerfile so we don't have to manually build it separately, simplifying the quick-start process * Added a healthcheck to make it easier to see when the container was done initializing. Currently a little ugly since it has to check both URLs for liveness * Removed CONDA_FORCE_UPDATE from env file since we don't user conda anymore Note - `build_docker.sh` is seemingly obsolete but I left it for now with a comment in case it's ingrained in somebody else's workflow. * Minor readme fixes
This commit is contained in:
parent
2966a3a2a2
commit
d28d07cd0b
@ -1,7 +1,3 @@
|
|||||||
# Force miniconda to attempt to update on every container restart
|
|
||||||
# instead only when changes are detected
|
|
||||||
CONDA_FORCE_UPDATE=false
|
|
||||||
|
|
||||||
# Validate the model files on every container restart
|
# Validate the model files on every container restart
|
||||||
# (useful to set to false after you're sure the model files are already in place)
|
# (useful to set to false after you're sure the model files are already in place)
|
||||||
VALIDATE_MODELS=true
|
VALIDATE_MODELS=true
|
||||||
|
@ -29,48 +29,43 @@ Other Notes:
|
|||||||
|
|
||||||
## First-Time Startup Instructions
|
## First-Time Startup Instructions
|
||||||
|
|
||||||
### Clone Repository and Build the Container Image
|
### Clone Repository
|
||||||
* Clone this repository to your host machine: `git clone https://github.com/sd-webui/stable-diffusion-webui.git`
|
* Clone this repository to your host machine:
|
||||||
* Change directories to your copy of the repository and run the Docker Image build script:
|
* `git clone https://github.com/sd-webui/stable-diffusion-webui.git`
|
||||||
* `cd https://github.com/sd-webui/stable-diffusion-webui.git`
|
|
||||||
* `./build_docker.sh`
|
|
||||||
* The build process will take several minutes to complete
|
|
||||||
* After the image build has completed, you will have a docker image for running the Stable Diffusion WebUI named `stable-diffusion-webui:dev`
|
|
||||||
* **The `stable-diffusion-webui:dev` Docker image will contain all software dependencies required to run Stable Diffusion and the Stable Diffusion WebUI; model files (i.e. weights/checkpoints) are stored separate from the Docker image. (Note: with this implementation, the Stable Diffusion WebUI code is also stored separate from the Docker image)**
|
|
||||||
|
|
||||||
* If you plan to use Docker Compose to run the image in a container (most users), create an `.env_docker` file using the example file:
|
* If you plan to use Docker Compose to run the image in a container (most users), create an `.env_docker` file using the example file:
|
||||||
* `cp .env_docker.example .env_docker`
|
* `cp .env_docker.example .env_docker`
|
||||||
* Edit `.env_docker` using the text editor of your choice.
|
* Edit `.env_docker` using the text editor of your choice.
|
||||||
* Options available in `.env_docker` allow you to control automatic model file checking/download during startup, and to select the Stable Diffusion WebUI implementation to run (Gradio vs Streamlit). **You must set the `VALIDATE_MODELS` option to `true` during the first run to download necessary model weights/checkpoints.** You may the set `VALIDATE_MODELS` option to `false` on future runs to speed up startup time.
|
* Ensure `VALIDATE_MODELS` is set to `true`
|
||||||
|
> Options available in `.env_docker` allow you to control automatic model file checking/download during startup, and to select the Stable Diffusion WebUI implementation to run (Gradio vs Streamlit). You may the set `VALIDATE_MODELS` option to `false` after the initial run (once models are downloaded) to speed up startup time.
|
||||||
|
|
||||||
|
|
||||||
### Create a Container Instance Using Docker Compose
|
### Create a Container Instance Using Docker Compose
|
||||||
During the first run of the image, several files will be downloaded automatically including model weights/checkpoints. After downloading, these files will be cached locally to speed up future runs.
|
|
||||||
|
|
||||||
The default `docker-compose.yml` file will create a Docker container instance named `sd-webui`
|
The default `docker-compose.yml` file will create a Docker container instance named `sd-webui`
|
||||||
|
|
||||||
* Create an instance of the Stable Diffusion WebUI image as a Docker container:
|
* Create an instance of the Stable Diffusion WebUI image as a Docker container:
|
||||||
* `docker compose up`
|
* `docker compose up`
|
||||||
|
* During the first run, the container image will be build containing all of the dependencies necessary to run Stable Diffusion. This build process will take several minutes to complete
|
||||||
|
* After the image build has completed, you will have a docker image for running the Stable Diffusion WebUI tagged `stable-diffusion-webui:dev`
|
||||||
|
|
||||||
(Optional) Daemon mode:
|
(Optional) Daemon mode:
|
||||||
* Note you can start the container in "daemon" mode by applying the `-d` option: `docker compose up -d`
|
* You can start the container in "daemon" mode by applying the `-d` option: `docker compose up -d`. This will run the server in the background so you can close your console window without losing your work.
|
||||||
* When running in daemon mode, you can view logging output from your container by running `docker logs sd-webui`
|
* When running in daemon mode, you can view logging output from your container by running `docker logs sd-webui`
|
||||||
|
|
||||||
(Note: Depending on your version of Docker/Docker Compose installed, the command may be `docker-compose` (older versions) or `docker compose` (newer versions))
|
> Note: Depending on your version of Docker/Docker Compose installed, the command may be `docker-compose` (older versions) or `docker compose` (newer versions)
|
||||||
|
|
||||||
The container may take several minutes to start up if model weights/checkpoints need to be downloaded.
|
|
||||||
|
|
||||||
|
|
||||||
### Accessing your Stable Diffusion WebUI Instance
|
### Accessing your Stable Diffusion WebUI Instance
|
||||||
Depending on the WebUI implementation you have selected, you can access the WebUI at the following URLs:
|
The container may take several minutes to start up if model weights/checkpoints need to be downloaded. You can view progress via `docker compose ps` to see the current status or by checking the logs using `docker compose logs`.
|
||||||
|
|
||||||
|
Depending on the WebUI implementation you selected in `.env_docker`, you can access the WebUI at the following URLs:
|
||||||
|
|
||||||
* Gradio: http://localhost:7860
|
* Gradio: http://localhost:7860
|
||||||
* Streamlit: http://localhost:8501
|
* Streamlit: http://localhost:8501
|
||||||
|
|
||||||
You can expose and access your WebUI to/from remote hosts by the machine's IP address:
|
You can expose and access your WebUI to/from remote hosts by the machine's IP address:
|
||||||
(note: This generally does not apply to Windows/WSL2 users due to WSL's implementation)
|
(note: This generally does not apply to Windows/WSL2 users due to WSL's implementation)
|
||||||
* Gradio: http://<host-ip-address>:7860
|
* Gradio: http://\<host-ip-address\>:7860
|
||||||
* Streamlit: http://<host-ip-address>:8501
|
* Streamlit: http://\<host-ip-address\>:8501
|
||||||
|
|
||||||
|
|
||||||
### Where is ___ stored?
|
### Where is ___ stored?
|
||||||
@ -101,8 +96,9 @@ You will need to re-download all associated model files/weights used by Stable D
|
|||||||
|
|
||||||
|
|
||||||
## Misc Related How-to
|
## Misc Related How-to
|
||||||
* You can obtain shell access to a running Stable Diffusion WebUI container started with Docker Compose with the following command:
|
* You can obtain shell access to a running Stable Diffusion WebUI container started with Docker Compose with either of the following commands:
|
||||||
* `docker exec -it st-webui /bin/bash`
|
* `docker exec -it st-webui /bin/bash`
|
||||||
|
* `docker compose exec stable-diffusion bash`
|
||||||
* To start a container using the Stable Diffusion WebUI Docker image without Docker Compose, you can do so with the following command:
|
* To start a container using the Stable Diffusion WebUI Docker image without Docker Compose, you can do so with the following command:
|
||||||
* `docker run --rm -it --entrypoint /bin/bash stable-diffusion-webui:dev`
|
* `docker run --rm -it --entrypoint /bin/bash stable-diffusion-webui:dev`
|
||||||
* To start a container, with mapped ports, GPU resource access, and a local directory bound as a container volume, you can do so with the following command:
|
* To start a container, with mapped ports, GPU resource access, and a local directory bound as a container volume, you can do so with the following command:
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# Functionally equivalent to docker compose build
|
||||||
docker build . -t stable-diffusion-webui:dev
|
docker build . -t stable-diffusion-webui:dev
|
||||||
|
@ -4,9 +4,10 @@ services:
|
|||||||
stable-diffusion:
|
stable-diffusion:
|
||||||
container_name: sd-webui
|
container_name: sd-webui
|
||||||
image: stable-diffusion-webui:dev
|
image: stable-diffusion-webui:dev
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
env_file: .env_docker
|
env_file: .env_docker
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/sd
|
- .:/sd
|
||||||
- ./outputs:/sd/outputs
|
- ./outputs:/sd/outputs
|
||||||
@ -15,6 +16,11 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- '7860:7860'
|
- '7860:7860'
|
||||||
- '8501:8501'
|
- '8501:8501'
|
||||||
|
healthcheck:
|
||||||
|
test: curl --fail http://localhost:8501 --head || curl --fail http://localhost:7860 --head || echo 1
|
||||||
|
interval: 30s
|
||||||
|
timeout: 1s
|
||||||
|
retries: 10
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
reservations:
|
reservations:
|
||||||
|
Loading…
Reference in New Issue
Block a user