containers / containers/podman-compose

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

Open
#1,445 0 comments 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

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:
```yml
web:
image: caddy:alpine
build: .
```
Run the service:
```console
$ podman-compose --verbose run --rm --service-ports --build web
...
INFO:podman_compose:podman build -f Containerfile -t caddy:alpine
...
# _web:latest is built..
Successfully tagged localhost/caddy:alpine
Successfully tagged localhost/_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:
```yml
web:
build: .
```
```console
$ podman-compose --verbose run --rm --service-ports --build web
...
# _web image is run properly
INFO:podman_compose:podman run ... _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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.