You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

内网中从其他机器访问树莓派Docker容器的ASP.NET Core应用失败求助

Troubleshooting ASP.NET Core Docker App Access on Raspberry Pi

Hey there, let's figure out why your ASP.NET Core app isn't accessible via your Raspberry Pi's IP on port 8080. I've dealt with similar Docker port issues on Pi before, so here are the most likely fixes and steps to debug:

1. Fix the Conflicting Network Mode & Port Mapping

Your command uses both -p 8080:80 (port forwarding) and --network=host—these two settings clash. When you use host network mode, Docker skips port forwarding entirely, and the container uses the Pi's network stack directly. That means your -p flag is being ignored.

Solutions:

  • Option 1: Drop the host network mode (simplest for most cases):
    Run this instead:

    docker run -d -p 8080:80 joro550/radiusnet
    

    Now you can access the app at http://<your-pi-ip>:8080 since the container's port 80 maps to the Pi's 8080.

  • Option 2: Keep host network mode, adjust app listening port:
    If you need host networking, you have to make sure your ASP.NET Core app listens on the port you want to access (e.g., 8080). You can do this in a few ways:

    • Add this to your app's Program.cs (or Startup.cs for older .NET versions):
      WebHost.CreateDefaultBuilder(args)
          .UseUrls("http://*:8080") // Listen on all interfaces, port 8080
          .UseStartup<Startup>();
      
    • Or set an environment variable when running the container:
      docker run -d --network=host -e ASPNETCORE_URLS=http://*:8080 joro550/radiusnet
      

    Then access the app at http://<your-pi-ip>:8080.

2. Verify the App is Listening on the Right Interface

Even if the container runs, your app might be only listening on the loopback address (127.0.0.1) instead of all interfaces (0.0.0.0), which blocks external access.

Check this by running:

docker exec <your-container-id> ss -tulpn

Look for a line like LISTEN 0 128 0.0.0.0:80 0.0.0.0:*—the 0.0.0.0 means it's listening on all interfaces. If you see 127.0.0.1, use the ASPNETCORE_URLS environment variable fix from step 1 to change it.

3. Check Raspberry Pi Firewall Rules

Your Pi's firewall might be blocking incoming traffic on port 8080. First, check if the firewall is active:

sudo ufw status

If it's enabled, allow the port with:

sudo ufw allow 8080/tcp

You can also temporarily disable the firewall to test if that's the issue:

sudo ufw disable

If the app becomes accessible, make sure to re-enable the firewall and add the port rule permanently.

4. Inspect Container Logs for App Startup Errors

Sometimes the container shows as "running" but the ASP.NET Core app failed to start properly. Check the logs for clues:

docker logs <your-container-id>

Look for errors like Failed to bind to address or startup exceptions—these will tell you exactly why the app isn't listening.

5. Ensure Your Docker Image Supports ARM Architecture

Raspberry Pi uses ARM-based processors (arm32 or arm64), so if your Docker image was built for x86/amd64, it might have compatibility issues even if it runs via QEMU emulation.

Double-check your Dockerfile uses an ARM-compatible base image, like:

  • For .NET 6/7 arm32: mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim-arm32v7
  • For arm64: mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim-arm64v8
    If you're using Docker Cloud for auto-builds, make sure you've enabled multi-architecture builds or specified ARM as the target architecture.

内容的提问来源于stack exchange,提问作者Mark Davies

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:33:17