podman-compose
podman-compose copied to clipboard
'podman-compose build' builds replicate images for each service in docker-compose.yaml that share a common image.
Summary
When executing podman-compose build
, a build is performed for each service in the docker-compose.yaml that share a common image.
This is not an issue in v1.0.6.
This was reproduced on the latest commit on the main branch (#16cbcf4)
Steps to reproduce
- Directory setup: project_directory/docker, which contains docker-compose.yaml, .env, Dockerfile
- Define docker-compose.yaml and Dockerfile (below)
- Execute
podman-compose build
from project_directory/docker
docker-compose.yaml:
x-common:
&common
image: project/dummy:0.1.0
build:
context: project_directory/docker
dockerfile: Dockerfile
services:
service1:
<<: *common
entrypoint: /bin/sh
command: -c "while :; do echo 'Hello, World!'; sleep 3600; done"
service2:
<<: *common
entrypoint: /bin/sh
command: -c "while :; do echo 'Hello, again!': sleep 3600; done"
service3:
<<: *common
entrypoint: /bin/sh
command: -c "while :; do echo 'Goodbye, World!'; sleep 3600; done"
Dockerfile:
FROM busybox:latest
RUN echo "hello world"
Expected behavior A clear and concise description of what you expected to happen.
Actual behavior Each service with a common images has a separate build
Output
$ podman-compose version
podman-compose version 1.1.0
podman version 4.9.4-rhel
podman --version
podman version 4.9.4-rhel
$ podman-compose build
STEP 1/2: FROM busybox:latest
STEP 1/2: FROM busybox:latest
STEP 1/2: FROM busybox:latest
STEP 2/2: RUN echo "hello world"
STEP 2/2: RUN echo "hello world"
STEP 2/2: RUN echo "hello world"
hello world
hello world
hello world
COMMIT project/dummy:0.0.1
COMMIT project/dummy:0.0.1
COMMIT project/dummy:0.0.1
--> 5a91e4e65d80
Successfully tagged localhost/project/dummy:0.0.1
5a91e4e65d803eccc851a72c9f835cc99492f851ad292d87d2723b68445ab2aa
--> 68b7cabbf235
Successfully tagged localhost/project/dummy:0.0.1
68b7cabbf235bc4cdeb2eb7c183ad6211ce165a7a8f0356e4b199e35df98c342
--> bb2e534fb9bd
Successfully tagged localhost/project/dummy:0.0.1
bb2e534fb9bd29df004dc3a4bc0a4cbcf9788e7278cff478b487a79f34da8383
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/project/dummy 0.0.1 bb2e534fb9bd 3 minutes ago 1.5 MB
<none> <none> 68b7cabbf235 3 minutes ago 1.5 MB
<none> <none> 5a91e4e65d80 3 minutes ago 1.5 MB
$ podman-compose up
...
[service3] | Goodbye, World!
[service1] | Hello, World!
[service2] | Hello, again!
Environment:
- OS: Linux
- podman version: 4.9.4-rhel
- podman compose version: 1.1.0 (#16cbcf4)
Additional Info: I have a work around, which is to define a 'build-dummy' service, and move the build info there:
docker-compose.yaml:
x-common:
&common
image: project/dummy:0.0.2
services:
build_dummy:
<<: *common
build:
context: project_directory/docker
dockerfile: Dockerfile
profiles:
- build
service1:
<<: *common
...
$ podman-compose build
STEP 1/2: FROM busybox:latest
STEP 2/2: RUN echo "hello world"
--> Using cache 5a91e4e65d803eccc851a72c9f835cc99492f851ad292d87d2723b68445ab2aa
COMMIT project/dummy:0.0.2
--> 5a91e4e65d80
Successfully tagged localhost/project/dummy:0.0.2
5a91e4e65d803eccc851a72c9f835cc99492f851ad292d87d2723b68445ab2aa
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/project/dummy 0.0.2 5a91e4e65d80 3 minutes ago 1.5 MB
$ podman-compose up
...
[service3] | Goodbye, World!
[service1] | Hello, World!
[service2] | Hello, again!