[Bug]: Binding host port < 1024 fails with permission error on explicit host IP (127.0.0.1:80), but succeeds on 0.0.0.0:80
- Dominant language
- Swift
- Stars
- 49.9k
- Forks
- 1.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 22
Description
### I have done the following
- [x] I have searched the existing issues
- [ ] If possible, I've reproduced the issue using the 'main' branch of this project
### **1. Steps to reproduce**
1. Attempt to bind host port 80 explicitly to `127.0.0.1`:
```bash
container run --rm -p 127.0.0.1:80:80/tcp hello-world
```
**Output:** `Error: failed to bootstrap container ... Permission denied while binding to host port 80. Binding to ports below 1024 requires root privileges.`
2. Attempt to bind host port 80 to `0.0.0.0` or without an explicit host IP:
```bash
container run --rm -p 0.0.0.0:80:80/tcp hello-world
# or
container run --rm -p 80:80/tcp hello-world
```
**Output:** `Hello from Docker!` (Succeeds)
3. Attempt to run with `sudo` to bypass the `127.0.0.1:80` error:
```bash
sudo container run --rm -p 127.0.0.1:80:80/tcp hello-world
```
**Output:** `Error: unauthorized request`
### **2. Problem description**
* Binding host port `< 1024` with `127.0.0.1` throws a permission validation error requiring root privileges.
* Binding host port `< 1024` with `0.0.0.0` or implicitly (`-p 80:80`) succeeds as a standard non-root user.
* Executing with `sudo` fails with `unauthorized request` due to a daemon UID mismatch (`client_euid=0` vs `server_euid=501`).
### **3. Expected Behavior**
Port binding validation for privileged ports (< 1024) should be consistent regardless of whether a specific host IP (`127.0.0.1`) or wildcard IP (`0.0.0.0`) is specified. Binding to `127.0.0.1:80` as a standard user should succeed just as `-p 80:80` and `-p 0.0.0.0:80:80` do.
### **4. System Logs (`container system logs`)**
```text
2026-07-22 15:23:33.032990+0700 0x5ce44a Error 0x0 43573 0 container-apiserver: [com.apple.container:APIServer] route handler threw an error [route=containerBootstrap] [error=internalError: "failed to bootstrap container 116a41dd-3486-4772-a76c-4cd6512663c6" (cause: "invalidArgument: "Permission denied while binding to host port 80. Binding to ports below 1024 requires root privileges."")]
2026-07-22 15:23:33.034473+0700 0x5ce468 Info 0x0 43573 0 container-apiserver: [com.apple.container:APIServer] ContainersService: enter [id=116a41dd-3486-4772-a76c-4cd6512663c6] [func=delete(id:force:)] [force=false]
2026-07-22 15:23:34.794230+0700 0x5cefc5 Error 0x0 43573 0 container-apiserver: [com.apple.container:APIServer] unauthorized request - uid mismatch [client_euid=0] [server_euid=501]
```
### **5. Environment**
```markdown
- OS: macOS 26.5.2 (Build 25F84)
- Xcode: Not installed
- Container: container CLI version 1.1.0 (build: release)
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start by reproducing the three port-binding commands from the issue on macOS and inspect the host-port validation path and daemon authorization behavior. Compare explicit 127.0.0.1 binding with wildcard or omitted host IP, including the logged UID mismatch. Done means privileged-port handling is consistent for these forms and regression coverage verifies the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, swift
- Domain
- infrastructure, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100