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

内部网络跨机器访问Docker容器:树莓派ASP.NET Core部署异常

Troubleshooting ASP.NET Core App Access Issues on Raspberry Pi via Docker

Let’s break down the problems and fix this step by step—your setup is almost there, just a few tweaks needed!

First: Fix the Conflicting Docker Run Command

Your current command has a critical conflict:

docker run -d -p 8080:80 joro550/radiusnet --network=host

When using --network=host, Docker bypasses its own network isolation and lets the container use the Raspberry Pi’s network stack directly. This means the -p 8080:80 port mapping is completely ignored—so your port forwarding isn’t working as expected. You need to pick one approach:

Option 1: Keep Container Network Isolation (Recommended)

Remove the --network=host flag, and keep the port mapping. This keeps your container isolated while still exposing it on port 8080:

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

Option 2: Use Host Network Mode

If you prefer host networking, drop the -p 8080:80 flag. Your ASP.NET Core app’s port 80 will directly map to the Raspberry Pi’s port 80:

docker run -d --network=host joro550/radiusnet

(Note: For this option, you’ll access the app via http://<raspberry-pi-ip> instead of port 8080)

Second: Ensure ASP.NET Core is Binding to the Right Address

A common gotcha with ASP.NET Core in containers: by default, the app binds only to localhost, which means it’s not accessible from outside the container. To fix this, you need to tell it to bind to all network interfaces (0.0.0.0).

You can do this two ways:

  • Add an environment variable to your docker run command:
    docker run -d -p 8080:80 -e ASPNETCORE_URLS=http://0.0.0.0:80 joro550/radiusnet
    
  • Or update your ASP.NET Core code’s host configuration:
    WebHost.CreateDefaultBuilder(args)
           .UseUrls("http://0.0.0.0:80")
           .UseStartup<Startup>();
    

Third: Verify the App is Running Inside the Container

Even if Docker says the container is running, the app might have failed to start. Check the container logs for errors:

docker logs <your-container-id>

You can get the container ID with docker ps. Look for any startup exceptions, port binding errors, or missing dependencies (common on ARM devices like Raspberry Pi).

You can also test the app directly inside the container to rule out network issues:

docker exec -it <your-container-id> curl localhost:80

If this returns your app’s content, the issue is definitely with external access (not the app itself).

Fourth: Check Raspberry Pi Firewall Settings

Make sure your Raspberry Pi’s firewall isn’t blocking the port you’re using. If you’re using ufw, check the status:

ufw status

If the port (8080 or 80) isn’t allowed, add a rule:

ufw allow 8080/tcp

Final Checks

  • Double-check your Raspberry Pi’s IP address (use hostname -I to confirm)
  • If using host network mode, ensure no other service on the Pi is already using port 80
  • Verify your Docker image is built for ARM architecture (Raspberry Pi uses ARM, not x86—Docker Cloud should handle this if you set up automated builds correctly, but it’s worth confirming)

内容的提问来源于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 04:07:02