Easypanel部署.NET应用遇Docker Unknown system error -8如何解决?
.NET应用在Easypanel部署时出现Docker buildx spawn错误(Unknown system error -8)
问题详情
我在VPS上托管了一个.NET 8应用,通过Easypanel管理。部署时触发以下错误:
Command failed with Unknown system error -8: docker buildx build --network host -f /etc/easypanel/projects/my_project/code/Dockerfile -t easypanel/my_project --label 'keep=true' --build-arg 'GIT_SHA=xxxxxxxxxxxxxxxxxxxxxxxx' /etc/easypanel/projects/my_project/code/
spawn Unknown system error -8
我的Dockerfile内容:
# Base image for runtime (used in final stage) FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app EXPOSE 8080 EXPOSE 8081 # Image used for building the application FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release ARG GIT_SHA=XXXXXXXXXXXXXXXXXXXXXXXXXXXX LABEL git_sha=$GIT_SHA WORKDIR /src # Copy and restore dependencies COPY ["MyProject/MyProject.csproj", "MyProject/"] RUN dotnet restore "./MyProject/MyProject.csproj" # Copy the entire source COPY . . WORKDIR "/src/MyProject" # Build with limited memory usage (1 thread to reduce memory use) RUN dotnet build "./MyProject.csproj" -c $BUILD_CONFIGURATION -m:1 -o /app/build # Publish the application FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "./MyProject.csproj" -c $BUILD_CONFIGURATION -m:1 -o /app/publish /p:UseAppHost=false # Final image FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "MyProject.dll"]
已尝试操作:
- 重新创建Easypanel应用
- 手动触发应用重建
- 重写Dockerfile(结构与原文件一致)
解决步骤
1. 排查文件描述符限制
Unknown system error -8通常对应系统或进程打开文件数超限,先做以下检查:
- 查看系统最大打开文件数:
cat /proc/sys/fs/file-max - 查看当前用户进程限制:
ulimit -n - 临时提升会话限制测试:
ulimit -n 65535,然后手动执行构建命令验证:
docker buildx build --network host -f /etc/easypanel/projects/my_project/code/Dockerfile -t easypanel/my_project --label 'keep=true' --build-arg 'GIT_SHA=xxxxxxxxxxxxxxxxxxxxxxxx' /etc/easypanel/projects/my_project/code/
如果临时生效,永久修改限制:编辑/etc/security/limits.conf,添加:
* soft nofile 65535 * hard nofile 65535
重启系统或重新登录生效。
2. 重置Docker buildx配置
Easypanel默认使用buildx构建,缓存或配置异常可能触发错误:
- 重置buildx:
docker buildx rm builder && docker buildx create --use - 强制无缓存构建:在Easypanel构建参数中添加
--no-cache,或在Dockerfile开头加入# syntax=docker/dockerfile:1.4指定语法版本。
3. 修改Easypanel构建命令
去掉--network host参数(部分VPS环境下host网络会触发资源限制),替换为默认网络构建:
修改构建命令为:
docker build -f /etc/easypanel/projects/my_project/code/Dockerfile -t easypanel/my_project --label 'keep=true' --build-arg 'GIT_SHA=xxxxxxxxxxxxxxxxxxxxxxxx' /etc/easypanel/projects/my_project/code/
(移除了buildx和--network host)
4. 检查VPS资源
- 查看内存使用:
free -h,内存不足时添加swap分区或升级VPS - 查看磁盘空间:
df -h,确保Docker存储目录(默认/var/lib/docker)有足够剩余空间
内容的提问来源于stack exchange,提问作者brunogomesc
相关产品推荐
相关产品推荐

