Skip to content

podman-compose errors with a traceback when compose file build context can not find a Dockerfile #1515

Description

@mokibit

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 <module>
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions