Repository navigation
Closed
Labels
bugSomething isn't working
Description
Describe the bug
Trying to execute the next composer code give "KeyError: 'postgres'":
version: "3"
services:
postgres:
container_name: PostgresSQL
image: postgres
environment:
POSTGRES_HOST_AUTH_METHOD: trust
PGDATA: /data/postgresql
volumes:
- postgresql:/data/postgresql
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: PgAdmin4
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL:
PGADMIN_DEFAULT_PASSWORD:
volumes:
- pgadmin:/var/lib.pgadmin
ports:
- "${PGADMIN_PORT:-5050}:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgresql:
pgadmin:
To Reproduce
Steps to reproduce the behavior:
- podman-compose -f postgresql.yml up (code above)
Output
$ podman-compose version
['podman', '--version', '']
using podman version: 4.2.0
podman-composer version 1.0.3
podman --version
podman version 4.2.0
$ podman-compose up
...
['podman', '--version', '']
using podman version: 4.2.0
** excluding: set()
podman volume inspect db_postgresql || podman volume create db_postgresql
['podman', 'volume', 'inspect', 'db_postgresql']
Traceback (most recent call last):
File "/usr/bin/podman-compose", line 33, in <module>
sys.exit(load_entry_point('podman-compose==1.0.3', 'console_scripts', 'podman-compose')())
File "/usr/lib/python3.10/site-packages/podman_compose.py", line 1774, in main
podman_compose.run()
File "/usr/lib/python3.10/site-packages/podman_compose.py", line 1023, in run
cmd(self, args)
File "/usr/lib/python3.10/site-packages/podman_compose.py", line 1247, in wrapped
return func(*args, **kw)
File "/usr/lib/python3.10/site-packages/podman_compose.py", line 1414, in compose_up
podman_args = container_to_args(compose, cnt, detached=args.detach)
File "/usr/lib/python3.10/site-packages/podman_compose.py", line 644, in container_to_args
assert_cnt_nets(compose, cnt)
File "/usr/lib/python3.10/site-packages/podman_compose.py", line 557, in assert_cnt_nets
net_desc = nets[net] or {}
KeyError: 'postgres'
With 1.0.4 (pip3 install git+https://github.com/containers/podman-compose.git@9d5b2559274819e3b47230da85d4d306807bb4bf)
podman-compose version: 1.0.4
['podman', '--version', '']
using podman version: 4.2.0
Traceback (most recent call last):
File "/home/wedc/bin/DevTools/pipenv/bin/podman-compose", line 33, in <module>
sys.exit(load_entry_point('podman-compose==1.0.4', 'console_scripts', 'podman-compose')())
File "/home/wedc/bin/DevTools/pipenv/lib64/python3.10/site-packages/podman_compose.py", line 2852, in main
podman_compose.run()
File "/home/wedc/bin/DevTools/pipenv/lib64/python3.10/site-packages/podman_compose.py", line 1383, in run
self._parse_compose_file()
File "/home/wedc/bin/DevTools/pipenv/lib64/python3.10/site-packages/podman_compose.py", line 1530, in _parse_compose_file
raise RuntimeError(f"missing networks: {missing_nets_str}")
RuntimeError: missing networks: postgres
Environment:
- OS: Linux / WSL / Mac: GNU/Linux openSUSE Tumbleweed
- podman version: 4.2.0
- podman compose version: (git hex) 1.0.3
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
mokibit commentedon Aug 31, 2026
I can reproduce this issue in the following environment:
I used the originally provided
compose.yml, and the output ofpodman-compose upis the same as reported by the original user.However, after taking a closer look at
compose.yml, the root cause seems to be invalid YAML indentation, not a bug inpodman-compose.The networks and volumes keys in the reported
compose.ymlare indented at the same level as the service definitions (postgres,pgadmin), which means YAML parsers treat them as additional services namednetworksandvolumes, rather than as top-level Compose keys.There is no top-level
networksorvolumessection, so whenpodman-composetries to resolve thepostgresnetwork referenced by the real services, it raisesRuntimeError: missing networks: postgres.On the other hand,
docker-composecatches this with a schema validation error that is more descriptive (andpodman-composeshould behave similarly):podman-composedoes not perform schema validation, so it silently acceptsnetworksandvolumesas service names and only fails later when resolving network references.Solution: When
networksandvolumesare moved to the top level (i.e., not nested under services), thepodman-compose upcommand works as expected.The
podman-composeerror message should be improved: it should detect that a service name is a reserved key (networks,volumes,secrets,configs) and emit a warning or a clearer error, similar todocker-compose's schema validation. I opened a dedicated issue for this: #1549.