podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

KeyError to network name

Open DevDorrejo opened this issue 3 years ago • 0 comments

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:

  1. 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

DevDorrejo avatar Sep 08 '22 13:09 DevDorrejo