0

I am using podman-compose with container-compose.yml file to build my containers which contains application and database container.

This is my container-compose.yml file looks like:

version: "3"
services:
  app:
    build: .
    ports:
      - "5001:5001"
    depends_on:
      - db
    environment:
      - DATABASE_URL=postgres://postgres:1234@db:5432/ApplicationYT
  db:
    image: postgres
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=1234
      - POSTGRES_DB=ApplicationYT
    volumes:
      - db-data:/var/lib/postgresql/data
volumes:
  db-data:

And I have Containerfile in the same path of container-compose.yml file. But when I am trying to use podman-compose to build it, I am getting error OSError: Dockerfile not found in /home/ubuntu/Project/learn_fastapi/Containerfile

This is the full error traceback:

(env) root@DESKTOP-S11P8K7:/home/ubuntu/Project/learn_fastapi★
# podman-compose build
Traceback (most recent call last):
  File "/home/ubuntu/Project/learn_fastapi/env/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/ubuntu/Project/learn_fastapi/env/lib/python3.12/site-packages/podman_compose.py", line 3309, in main
    asyncio.run(async_main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/ubuntu/Project/learn_fastapi/env/lib/python3.12/site-packages/podman_compose.py", line 3305, in async_main
    await podman_compose.run()
  File "/home/ubuntu/Project/learn_fastapi/env/lib/python3.12/site-packages/podman_compose.py", line 1635, in run
    retcode = await cmd(self, args)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/Project/learn_fastapi/env/lib/python3.12/site-packages/podman_compose.py", line 2272, in compose_build
    s = await t
        ^^^^^^^
  File "/usr/lib/python3.12/asyncio/tasks.py", line 631, in _wait_for_one
    return f.result()  # May raise f.exception().
           ^^^^^^^^^^
  File "/home/ubuntu/Project/learn_fastapi/env/lib/python3.12/site-packages/podman_compose.py", line 2225, in build_one
    raise OSError("Dockerfile not found in " + ctx)
OSError: Dockerfile not found in /home/ubuntu/Project/learn_fastapi/Containerfile

It looks like I may have missed something but I have tried to find the resources on how to use Containerfile instead of Dockerfile but I could not find it. And I can use Dockerfile but I don't want to, I just want to continue to podman specific naming conventions.

This are the details about the podman and podman-compose:

podman-compose version 1.1.0
podman version 4.9.3

If anyone can direct in correct direction, I will be very glad. Thank you.

1 Answer 1

1

It looks like you hit this bug:

1.1.0 (and perhaps above) broke the use of Containerfiles #977

You can rename (or symlink) your Containerfile to Dockerfile, or add a dockerfile: Containerfile attribute to your build directive:

services:
  app:
    build:
      context: .
      dockerfile: Containerfile
5
  • I have added dockerfile: Containerfile attribute, but still the same. And yes, it looks like the bug and it seems someone suggested the fix as well. I hope it will get merged and released soon. Commented Jun 26 at 13:38
  • Using dockerfile: Containerfile works just fine; I tried it before posting the answer. I suspect you may have an error in your compose file.
    – larsks
    Commented Jun 26 at 13:41
  • Ok, if that's the case then I am not sure why I am seeing the same error. I mean I should see some different error if there is an issue with my compose or Containerfile. Commented Jun 26 at 15:02
  • 1
    Here's an example of a successful build: asciinema.org/a/GOfJxu1cGJMSpdkbRIrKXXXei
    – larsks
    Commented Jun 26 at 15:08
  • Yeah. I don't know what I missed but I deleted the compose file completed, build new one using your example and then it worked like a charm! Thank you very much! Commented Jun 26 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.