Skip to content

build: image is not used if image: is also set #1445

@bam80

Description

@bam80

If both build: and image: are present, the image builds but is not used, and it's impossible to make use of it even with --build option:

  web:
    image: caddy:alpine
    build: .

Run the service:

$ podman-compose --verbose run --rm --service-ports --build web
...
INFO:podman_compose:podman build -f Containerfile -t caddy:alpine <compose dir>
...
# <compose dir>_web:latest is built..
Successfully tagged localhost/caddy:alpine
Successfully tagged localhost/<compose dir>_web:latest
...
# ..but is not used then - downloaded caddy:alpine is run instead
INFO:podman_compose:podman run ... caddy:alpine

If we remove image:, the image built is used then properly:

  web:
    build: .
$ podman-compose --verbose run --rm --service-ports --build web
...
# <compose dir>_web image is run properly
INFO:podman_compose:podman run ... <compose dir>_web

This behavior doesn't correspond to docker-compose, where build: has a preference.

$ podman-compose version
podman-compose version 1.5.0
podman version 5.8.2

Environment:

  • OS: Linux

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