[Bug]: --publish rejects port 1 as out of range
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Start in Sources/Services/ContainerAPIService/Client/Parser.swift at Parser.publishPort around line 704, then run the two --publish reproductions from the issue. Done means port 1 is accepted for host, container, and range endpoints while port 0 remains rejected.
Written by the indexing model from the issue text.
Description
I have done the following
- I have searched the existing issues
- If possible, I've reproduced the issue using the 'main' branch of this project
Steps to reproduce
Publish either side of a port mapping on port 1:
container run --rm --publish 1:80 nginx
container run --rm --publish 8080:1 nginx
Both fail:
invalid publish host port range: 1
invalid publish container port range: 1
Problem description
Parser.publishPort validates the parsed range with a strict greater-than:
guard hostPortRangeStart > 1,
hostPortRangeStart <= hostPortRangeEnd
else { ... }
guard containerPortRangeStart > 1,
containerPortRangeStart <= containerPortRangeEnd
else { ... }
TCP and UDP port numbers run from 1 to 65535, so the lower bound should be >= 1. The current comparison also rejects port 1 at the start of a range, so --publish 1-100:1-100 fails as well.
Port 0 is correctly rejected either way, since it means "any port" rather than a specific one.
Environment
- OS: macOS 26.5.2 (25F84)
- Xcode: 26.6 (17F113)
- Container: main at 07ff3c0 (also present in 1.1.0)
Code of Conduct
- I agree to follow this project's Code of Conduct
- Dominant language
- Swift
- Stars
- 50.1k
- Forks
- 1.8k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apple/container
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
type: docs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
googleapis/google-cloud-swift#971 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
manaflow-ai/cmux#13417 ·