podman-compose
podman-compose copied to clipboard
Crash on Empty Ports Specification
If you define a ports section, but leave it empty. It will cause podman-compose to crash on "up" command.
example yml:
version: "3"
services:
flask-service:
build: ./flask
container_name: flask-service
restart: always
# notice, we added a "z" so that we can be changing the
# file in the directory, and it will change in the container
volumes:
- ./flask/app:/opt/flask:z
ports:
# using internal port to communicate to webserver
# - 9090:9090
Fixed it like so (around line 465 in version 0.1.5):
# added this extra check
if not (cnt.get('ports') is None):
for i in cnt.get('ports', []):
podman_args.extend(['-p', i])
This is probably not the only place this happens, probably other empty sections will cause the same crash. Maybe the yml parser should be more strict and give an appropriate error message like: ERROR: Ports section is empty.
This is version 0.1.5.
Same for empty volumes, with the following example:
version: "3"
services:
test:
image: alpine
volumes:
# ./test:/test
podman-compose up outputs:
Traceback (most recent call last):
File "~/.local/bin/podman-compose", line 11, in <module>
sys.exit(main())
File "~/.local/lib/python3.6/site-packages/podman_compose.py", line 2941, in main
podman_compose.run()
File "~/.local/lib/python3.6/site-packages/podman_compose.py", line 1423, in run
cmd(self, args)
File "~/.local/lib/python3.6/site-packages/podman_compose.py", line 1754, in wrapped
return func(*args, **kw)
File "~/.local/lib/python3.6/site-packages/podman_compose.py", line 2067, in compose_up
podman_args = container_to_args(compose, cnt, detached=args.detach)
File "~/.local/lib/python3.6/site-packages/podman_compose.py", line 900, in container_to_args
for volume in cnt.get("volumes", []):
TypeError: 'NoneType' object is not iterable
In comparison, docker compose outputs a clearer message:
validating ~/test/docker-compose.yaml: services.test.volumes must be a list
My version is 1.0.6