`extra_hosts` entries written as `HOSTNAME=IP` fail with "bad format for add-host"
Maintainers usually reply within 4 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Search the repository for --add-host and for the cnt.get("extra_hosts", []) loop shown in the report; it appears in both the run and the build argument paths, and neither normalises the entry. Read the extra_hosts section of the compose-spec document linked in the issue, then convert a leading HOSTNAME= into HOSTNAME: while leaving already-colonised entries untouched, including bracketed IPv6 like myhostv6=[::1]. Reproduce with the small busybox compose file given and confirm both podman-compose up and a build path pass a value Podman accepts, with /etc/hosts showing 10.1.2.3 foo.example.
Written by the indexing model from the issue text.
Description
Describe the bug
The Compose specification allows an extra_hosts entry to be written either as HOSTNAME=IP or as HOSTNAME:IP (the = separator is the preferred form in the spec). podman-compose passes each entry to podman --add-host unchanged, and Podman accepts only the colon form, so a compose file using = fails to create the container.
To Reproduce
compose.yaml:
services:
web:
image: docker.io/library/busybox
command: ["cat", "/etc/hosts"]
extra_hosts:
- "foo.example=10.1.2.3"
$ podman-compose up
Expected behavior
The container starts and /etc/hosts holds 10.1.2.3 foo.example, as it does with docker compose and as it does here when the entry is written foo.example:10.1.2.3.
Actual behavior
Error: bad format for add-host: "foo.example=10.1.2.3"
[web] | Error: no container with name or ID "..._web_1" found: no such container
Changing only the separator to : makes the same file work:
[web] | 10.1.2.3 foo.example
Cause
On current main the entries are still forwarded as they are, for both run and build:
for i in cnt.get("extra_hosts", []):
podman_args.extend(["--add-host", i])
Normalising HOSTNAME=IP to HOSTNAME:IP before passing it on would cover it. An IPv6 address in brackets, myhostv6=[::1], is the other spelling the spec lists.
Environment
- OS: Linux
- podman version: 5.7.0
- podman-compose version: 1.5.0 (the code path is unchanged on
main)
- Dominant language
- Python
- Stars
- 6.3k
- Forks
- 647
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 containers/podman-compose
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
containers/podman-compose#1652 ·
Maintainers usually reply within 4 days
-
`pull` silently ignores unknown service names and exits 0Possibly taken @PacketBreaker claimed this 7 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
containers/podman-compose#1640 · 1 comment ·
Maintainers usually reply within 4 days
-
`name_separator_compat` also changes network names, which docker compose does not doPossibly taken @Eliot5566 claimed this 12 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
containers/podman-compose#1628 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
containers/podman-compose#1619 · 3 comments · 1 reaction ·
Maintainers usually reply within 4 days
-
Support for services.attachPossibly taken @orshih6 claimed this 11 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
containers/podman-compose#1597 ·
Maintainers usually reply within 4 days
All issues in containers/podman-compose
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day
-
polish
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPossibly taken @AshutoshSingh840 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainers usually reply within 1 day