containers / containers/podman-compose

`podman-compose up` fails if parent folder is not a valid tag format

Open
#802 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

**To Reproduce**
Steps to reproduce the behavior:
```bash
mkdir _test
cd _test
echo "FROM docker.io/nginx:latest" > Dockerfile
cat < compose.yaml
---
services:
nginx:
build: .
EOF
podman-compose up --build
```

**Output**

```console
$ python ../podman-compose/podman_compose.py up
podman-compose version: 1.0.7
['podman', '--version', '']
using podman version: 4.7.2
** excluding: set()
['podman', 'inspect', '-t', 'image', '-f', '{{.Id}}', '_test_nginx']
Error: invalid reference format
podman build -f /tmp/tmp.1d20dwmcrw/_test/Dockerfile -t _test_nginx /tmp/tmp.1d20dwmcrw/_test
Error: tag _test_nginx: invalid reference format
exit code: 125
['podman', 'ps', '--filter', 'label=io.podman.compose.project=_test', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
podman pod create --name=pod__test --infra=false --share=
Error: adding pod to state: name "pod__test" is in use: pod already exists
exit code: 125
['podman', 'network', 'exists', '_test_default']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=_test', '--label', 'com.docker.compose.project=_test', '_test_default']
Error: network name _test_default invalid: names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: invalid argument
Traceback (most recent call last):
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 736, in assert_cnt_nets
compose.podman.output([], "network", ["exists", net_name])
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 1169, in output
return subprocess.check_output(cmd_ls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['podman', 'network', 'exists', '_test_default']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 3209, in
main()
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 3205, in main
podman_compose.run()
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 1524, in run
retcode = cmd(self, args)
^^^^^^^^^^^^^^^
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 1920, in wrapped
return func(*args, **kw)
^^^^^^^^^^^^^^^^^
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 2254, in compose_up
podman_args = container_to_args(compose, cnt, detached=args.detach)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 960, in container_to_args
assert_cnt_nets(compose, cnt)
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 779, in assert_cnt_nets
compose.podman.output([], "network", args)
File "/tmp/tmp.1d20dwmcrw/_test/../podman-compose/podman_compose.py", line 1169, in output
return subprocess.check_output(cmd_ls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['podman', 'network', 'create', '--label', 'io.podman.compose.project=_test', '--label', 'com.docker.compose.project=_test', '_test_default']' returned non-zero exit status 125.
```

**Environment:**
- OS: Linux 6.6.1-arch1-1
- podman version: 4.7.2
- podman compose version: 1.0.6 (f6dbce3) and latest (bce40c2)

Contributor guide

Open the contributing guide

Research direction

Start in podman_compose.py around compose_up, container_to_args, and assert_cnt_nets, then reproduce the failure with the documented mkdir, Dockerfile, compose.yaml, and podman-compose up --build commands. Trace how the _test project name becomes image, pod, and network names; done means the same compose project starts successfully when its parent folder begins with an underscore.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.