# Docker 安装指南

# 安装

# Linux

  1. 请按照此处的 Docker 安装指南安装 Docker。

  2. 按照 Docker 安装后配置指南中的以非 root 用户身份管理 Docker部分进行操作。

  3. 使用包管理器安装 Git

    • Debian (Ubuntu/Pop! OS/等)

      sudo apt install git
    • Arch Linux (Manjaro/EndeavourOS/等)

      sudo pacman -S git
    • Fedora, Red Hat Enterprise Linux (RHEL), 等

      sudo dnf install git
  4. 克隆 SillyTavern 仓库。

    • Release (稳定分支)

      git clone https://github.com/SillyTavern/SillyTavern && cd SillyTavern/docker
    • Staging (开发分支)

      git clone https://github.com/SillyTavern/SillyTavern -b staging && cd SillyTavern/docker
  5. 在 Docker 文件夹中运行以下命令执行 docker compose

    docker compose up -d
  6. 执行以下 Docker 命令获取 SillyTavern Docker 容器的 IP 地址。

    docker network inspect docker_default

    您应该会看到类似下面的输出:

    [
        {
            "Name": "docker_default",
            "IPAM": {
                "Config": [
                    {
                        "Subnet": "172.18.0.0/16",
                        "Gateway": "172.18.0.1"
                    }
                ]
            }
        }
    ]

    记下您在 Gateway 中看到的 IP 地址,这很重要。

  7. 使用 sudo 打开 nano 并运行以下命令:

    sudo nano config/config.yaml

    nano 中,找到 whitelist。您应该会看到类似下面的内容:

    whitelist:
        - 127.0.0.1

    127.0.0.1 下面添加一行,输入您从 Docker 复制的 IP 地址。完成后应该类似这样:

    whitelist:
        - 127.0.0.1
        - 172.18.0.1

    Ctrl+S 保存文件,然后按 Ctrl+X 退出 nano

  8. 重启 Docker 容器以应用新配置。

    docker compose restart sillytavern
  9. 打开新的浏览器并访问 http://localhost:8000。几分钟后您应该就能看到 SillyTavern 加载完成。

  10. 尽情享用! :D

# Windows

  1. 按照此处的 Docker 安装指南安装 Docker Desktop。

  2. 安装 Git for Windows

  3. 克隆 SillyTavern 仓库。

    • Release (稳定分支)

      git clone https://github.com/SillyTavern/SillyTavern && cd SillyTavern/docker
    • Staging (开发分支)

      git clone https://github.com/SillyTavern/SillyTavern -b staging && cd SillyTavern/docker
  4. 在 Docker 文件夹中运行以下命令执行 docker compose

    docker compose up -d
  5. 执行以下 Docker 命令获取 SillyTavern Docker 容器的 IP 地址。

    docker network inspect docker_default

    您应该会看到类似下面的输出:

    [
        {
            "Name": "docker_default",
            "IPAM": {
                "Config": [
                    {
                        "Subnet": "172.18.0.0/16",
                        "Gateway": "172.18.0.1"
                    }
                ]
            }
        }
    ]

    记下您在 Gateway 中看到的 IP 地址,这很重要。

  6. 以管理员权限运行 Notepad 或您选择的代码编辑器,进入 config 目录并打开 config.yaml

    在您选择的编辑器中,您应该会看到类似下面的内容:

    whitelist:
        - 127.0.0.1

    127.0.0.1 下面添加一行,输入您从 Docker 复制的 IP 地址。完成后应该类似这样:

    whitelist:
        - 127.0.0.1
        - 172.18.0.1

    Ctrl+S 保存文件,然后退出编辑器。

  7. 重启 Docker 容器以应用新配置。

    docker compose restart sillytavern
  8. 打开新的浏览器并访问 http://localhost:8000。几分钟后您应该就能看到 SillyTavern 加载完成。

  9. 尽情享用! :D

# macOS

  1. 按照此处的 Docker 安装指南安装 Docker Desktop。

  2. 使用 Homebrew 安装 git

    brew install git
  3. 克隆 SillyTavern 仓库。

    • Release (稳定分支)

      git clone https://github.com/SillyTavern/SillyTavern && cd SillyTavern/docker
    • Staging (开发分支)

      git clone https://github.com/SillyTavern/SillyTavern -b staging && cd SillyTavern/docker
  4. 在 Docker 文件夹中运行以下命令执行 docker compose

    docker compose up -d
  5. 执行以下 Docker 命令获取 SillyTavern Docker 容器的 IP 地址。

    docker network inspect docker_default

    您应该会看到类似下面的输出:

    [
        {
            "Name": "docker_default",
            "IPAM": {
                "Config": [
                    {
                        "Subnet": "172.18.0.0/16",
                        "Gateway": "172.18.0.1"
                    }
                ]
            }
        }
    ]

    记下您在 Gateway 中看到的 IP 地址,这很重要。

  6. 使用 sudo 打开 nano 并运行以下命令。

    sudo nano config/config.yaml

    Within nano, go down to whitelist. You should see something similar to the following below.

    whitelist:
        - 127.0.0.1

    Add a new line below 127.0.0.1 and put in the IP you copied from Docker. It should look something similar to the following afterwards.

    whitelist:
        - 127.0.0.1
        - 172.18.0.1

    Save the file by pressing Ctrl+S then exit nano by pressing Ctrl+X.

  7. Restart the Docker Container to apply the new configuration.

    docker compose restart sillytavern
  8. Open an new browser and go to http://localhost:8000. You should see SillyTavern load in a few moments.

  9. Enjoy! :D

# Configuring SillyTavern

SillyTavern's configuration file (config.yaml) will be located within the config folder. Configuring the config file should be no different than configuring it without Docker, however you will need to run nano or a code editor with administrator rights in order to save your changes.

# Locating User Data

SillyTavern's data folder will be within the data folder. Backing up your files should be easy to do, however, restoring or adding content into it may require you to do so with administrator rights.

# Running Server Plugins

Running plugins like HoYoWiki-Scraper-TS or SillyTavern-Fandom-Scraper within Docker is no different from running it on your system without Docker, however we will need to do a slight modification to the Docker Compose script in order to do so.

  1. Using nano or a code editor, open docker-compose.yml and add the following line below volumes.

        volumes:
            - "./config:/home/node/app/config"
            - "./data:/home/node/app/data"
            - "./plugins:/home/node/app/plugins"
  2. Create a new folder within the docker folder called plugins.

  3. Follow your plugin's instructions on installing the plugin.

  4. Using nano or a code editor with administrator rights, open config.yaml (within the config folder) and enable enableServerPlugins

    enableServerPlugins: true
  5. Restart the Docker container.

    docker compose restart sillytavern
  6. Profit.