`extra_hosts` entries written as `HOSTNAME=IP` fail with "bad format for add-host"

Open Beginner friendly
#1,620 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

@Eliot5566 is already working on this.

Since Nov 18, 2026.

  • #1621 by @Eliot5566 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from containers/podman-compose

All issues in containers/podman-compose

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.