containers / containers/podman-compose
`podman-compose` errors with a traceback when compose file `build` context can not find a Dockerfile
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When the `build` key in the `compose.yml` file is given a string representing a context directory and the `Dockerfile` cannot be found in that directory, it throws an error traceback that pollutes the output and is unnecessary for the user to see.
**To Reproduce**
`compose.yml`:
```
services:
server:
container_name: server
build: ./Dockerfile
command: sh -c "echo 'hello'"
```
The build argument represents a directory in which to search for a Dockerfile.
If the specified directory does not contain a Dockerfile, `podman-compose` rightfully throws an error.
Here, `Dockerfile` represents a file, and even if it exits, `podman-compose` does not find it (as expected).
Call `podman-compose build`.
**Expected behavior**
Only one line of error is shown, e.g.:
`OSError: Dockerfile not found in /a/b/c/Dockerfile`
**Actual behavior**
The entire error traceback is shown:
```
Traceback (most recent call last):
File "/a/b/c/./podman_compose.py", line 5462, in
main()
~~~~^^
File "/a/b/c/./podman_compose.py", line 5455, in main
asyncio.run(async_main())
<...>
OSError: Dockerfile not found in /a/b/c/Dockerfile
```
**Environment:**
Debian GNU/Linux 13 (trixie)
Python 3.13.5
podman-compose version 1.6.0
podman version 5.4.2
**Additional context**
This should behave similarly to `docker-compose`:
```
$ docker-compose build
[+] Building 0.0s (0/0) docker:default
unable to prepare context: path "/a/b/c/Dockerfile" not found
```
Contributor guide
Research direction
Start in podman_compose.py at the main entry point shown in the traceback and trace how the missing Dockerfile error from `podman-compose build` is reported. Reproduce the invalid `build: ./Dockerfile` context, then verify the command emits only the expected OSError line rather than a traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100