首页 > 解决方案 > C# Discord Bot - Docker 容器中的 SQLite 错误

问题描述

我正在尝试通过 Docker 在带有 DSharp 库的 VPS(Ubuntu 18.04 x64)上部署 .NET-Core Discord-Bot。

我的项目包括一个 SQLite 数据库。使用 Visual Studio 手动运行数据时,我可以毫无问题地访问数据,而且我的机器人也发送命令。

但是,当我在启动机器人并使用 Docker 运行时尝试发送命令时,出现以下异常:

code = 277 (277), message = System.Data.SQLite.SQLiteException (0x800007EF): bad parameter or other API misuse

at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)

at System.Data.SQLite.SQLiteConnection.Open()

at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)

这是我的 docker-compose.yml 文件:

version: "3"
services:
  bot:
    build: .
    image: mydiscordbot

这是我的码头文件:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .

COPY config.json ./
COPY App.config ./
ENTRYPOINT ["dotnet", "bot.dll"]

我正在加载连接字符串以从 App.config 访问我的数据库。

标签: c#dockersqlitediscorddsharp+

解决方案


推荐阅读