Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
1 result

stable-diffusion-webui-docker

  • Clone with SSH
  • Clone with HTTPS
  • Jan Grewe's avatar
    Jan Grewe authored
    083aed3e
    History

    Stable Diffusion WebUI in Docker

    This builds a Docker image containing the Stable Diffusion WebUI by AUTOMATIC111 from https://github.com/AUTOMATIC1111/stable-diffusion-webui

    Build the image (and optionally push it to your registry)

    Set the version and image name to use:

    export VERSION="v1.x.y"
    export IMAGE_NAME=registry.example.com/stable-diffusion-webui

    Build the image and also add the latest tag:

    docker build --build-arg VERSION=${VERSION} -t ${IMAGE_NAME}:${VERSION} .
    docker tag ${IMAGE_NAME}:${VERSION} ${IMAGE_NAME}:latest

    Optionally, push both tags to your registry:

    docker push ${IMAGE_NAME}:${VERSION}
    docker push ${IMAGE_NAME}:latest

    Building an OCI image

    nerdctl build --progress=plain --build-arg="VERSION=${VERSION}" --output="type=oci,name=${IMAGE_NAME}:${VERSION},push=true" -t ${IMAGE_NAME}:${VERSION} .

    Run the container

    Run the image without retaining any data or outputs on exit:

    docker run --gpus all --rm --name stable-diffusion -p 7860:7860 ${IMAGE_NAME}:latest

    Run the image with persisted models, downloaded data and outputs:

    docker run --tty --gpus all --rm --name stable-diffusion-webui -p 7860:7860 \
      -v /storage/stable-diffusion/data/:/app/data \
      -v /storage/stable-diffusion/repositories:/app/repositories \
      -v /storage/stable-diffusion/cache:/root/.cache \
      -v /storage/stable-diffusion/outputs:/app/outputs \
      ${IMAGE_NAME}:latest

    Troubleshooting

    • There is no output to the console when starting the image until you generate an image. This can be fixed by adding the --tty argument after docker run