c# - 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 访问我的数据库。
解决方案
推荐阅读
- python - 如何从 Torrent 文件中删除某些不需要的文件?
- laravel - Laravel 分页漂亮的网址
- python - 具有自定义聚合功能的 pandas 数据帧上的 groupby
- python-3.x - Python 3:使用函数中的最后一个参数
- laravel - 我应该如何在中间件和控制器之间传递数据?
- busybox - 如何在 bash/ash 脚本中读取时防止 ANSI 转义键序列显示垃圾邮件?
- c - C:switch 语句中的错误:“这是与该值重叠的第一个条目”
- c++ - 有人可以解释这个 c++ 代码的区别吗?
- javascript - Bootstrap 3 Multi Item Carousel 一次只显示一个项目
- css - JavaFX Dropshadow CSS:参数是什么意思?如何在 CSS 中实现宽度和高度?