谷歌云Ubuntu虚拟机中Docker BusyBox容器无法外部IP访问
Let’s break down why you’re hitting that "site unreachable" error and fix it step by step:
The Root Problem: BusyBox Doesn’t Run a Web Service by Default
When you start a BusyBox container with just the sh command, it only spins up a shell session—there’s no web server listening on port 8080 (the container port you mapped to your host’s ports). That’s why your external URLs aren’t working.
Step 1: Confirm No Service is Listening in the Container
First, verify there’s nothing running on port 8080 inside your containers. Run this for each container (swap bb1 with tt3 for the other one):
docker exec -it bb1 netstat -tulpn
If netstat isn’t available, use BusyBox’s built-in tool:
docker exec -it bb1 ss -tulpn
You’ll almost certainly see no entries for port 8080—proof no service is active there.
Step 2: Start a Simple Web Service in the Container
BusyBox includes a tiny built-in web server called httpd. Let’s get it running:
- Jump into the container shell:
docker exec -it bb1 sh - Create a test HTML file so you have something to view:
echo "<h1>Hello from BusyBox!</h1>" > /tmp/index.html - Launch the web server on port 8080, using
/tmpas the web root:httpd -p 8080 -h /tmp - Exit the shell with
Ctrl+D.
Repeat these steps for your tt3 container too.
Step 3: Test Locally First
Before trying your external IP, test from your host machine to rule out port mapping issues:
- For
bb1:curl http://localhost:32769 - For
tt3:curl http://localhost:80
If you see your test HTML content, the container service and port mapping are working correctly.
Step 4: Fix External Access Blockages
If local access works but external access fails:
- Check your host firewall: Make sure tools like
ufw(Ubuntu) oriptablesallow incoming traffic on ports 80 and 32769. - Check cloud security groups: If you’re using a cloud server (like Google Cloud), confirm your instance’s security group has rules permitting inbound traffic on those ports (allow your external IP specifically, or
0.0.0.0/0for testing).
Pro Tip: Start the Web Service Automatically
Avoid manually starting httpd every time by launching the container with the web server command directly:
docker run -d -p 80:8080 --name tt3 busybox httpd -p 8080 -h /tmp
This way, the web server boots up as soon as the container starts.
内容的提问来源于stack exchange,提问作者SHC

