containers / containers/podman-compose
`pull_policy` of `build` is ignored
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I have a `compose.yaml` file where I want the service's image to be rebuilt every time it is started, using the below:
- `compose.yaml`
```yaml
name: myservice
services:
myservice:
build:
context: .
dockerfile: Dockerfile
image: localhost/myservice
pull_policy: build
container_name: myservice
```
- `Dockerfile`
```Dockerfile
FROM quay.io/podman/hello
COPY example.txt example.txt
```
- `example.txt`
```txt
example
```
However, the `build` value for `pull_policy` seems to be ignored, resulting in the image not being rebuilt. Normally the image should be rebuilt on every start (even when there are no changes to the `Dockerfile`), but this is not happening (even if I make changes).
If the image does not exist already, then it will be built, albeit after throwing an error:
> Error: inspecting object: unable to inspect "localhost/myservice": failed to find image localhost/myservice: localhost/myservice: image not known
**To Reproduce**
Steps to reproduce the behavior (all in the same directory):
1. Create the above files
2. Run `podman-compose up`
3. Run `podman-compose down`
4. Run `podman-compose up`
**Expected behavior**
The `localhost/myservice` image to be built on both executions of `podman-compose up`.
**Actual behavior**
The `localhost/myservice` image was only built on the first execution of `podman-compose up`.
**Output**
Version and command output
```
PS C:\Users\$USER\dev\docker\myservice> podman-compose version
['podman', '--version', '']
using podman version: 4.3.1
podman-composer version 1.0.3
podman --version
podman version 4.3.1
exit code: 0
PS C:\Users\$USER\dev\docker\myservice> podman-compose up
['podman', '--version', '']
using podman version: 4.3.1
** excluding: set()
['podman', 'inspect', '-t', 'image', '-f', '{{.Id}}', 'localhost/myservice']
Error: inspecting object: unable to inspect "localhost/myservice": failed to find image localhost/myservice: localhost/myservice: image not known
podman build -t localhost/myservice -f .\Dockerfile .
STEP 1/2: FROM quay.io/podman/hello
Trying to pull quay.io/podman/hello:latest...
Getting image source signatures
Copying blob sha256:affae3fe34b25d4cc304c60c59e5c531abf70c8c942d568386797e71bc79ec93
Copying config sha256:08d72d881de32ac1bb7e1228c5fb158fc0f44c71a0f7adc2c5a5de9adffa4f8f
Writing manifest to image destination
Storing signatures
STEP 2/2: COPY example.txt example.txt
COMMIT localhost/myservice
--> e901caf7587
Successfully tagged localhost/myservice:latest
e901caf7587f14fa5baff132dd011a8cad45b35f77a8a7fe1116a525efd979b6
exit code: 0
['podman', 'network', 'exists', 'myservice_default']
podman create --name=myservice --label io.podman.compose.config-hash=123 --label io.podman.compose.project=myservice --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=myservice --label com.docker.compose.project.working_dir=C:\Users\$USER\dev\docker\myservice --label com.docker.compose.project.config_files=compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=myservice --net myservice_default --network-alias myservice localhost/myservice
584c94fabf8b521d08000cb613b743200bbb68d2db726b925847c58d237e594d
exit code: 0
podman start -a myservice
!... Hello Podman World ...!
.--"--.
/ - - \
/ (O) (O) \
~~~| -=(,Y,)=- |
.---. /` \ |~~
~/ o o \~~~~.----. ~~
| =(X)= |~ / (O (O) \
~~~~~~~ ~| =(Y_)=- |
~~~~ ~~~| U |~~
Project: https://github.com/containers/podman
Website: https://podman.io
Documents: https://docs.podman.io
Twitter: @Podman_io
exit code: 0
PS C:\Users\$USER\dev\docker\myservice> podman-compose down
['podman', '--version', '']
using podman version: 4.3.1
** excluding: set()
podman stop -t 10 myservice
myservice
exit code: 0
podman rm myservice
myservice
exit code: 0
PS C:\Users\$USER\dev\docker\myservice> podman-compose up
['podman', '--version', '']
using podman version: 4.3.1
** excluding: set()
['podman', 'inspect', '-t', 'image', '-f', '{{.Id}}', 'localhost/myservice']
['podman', 'network', 'exists', 'myservice_default']
podman create --name=myservice --label io.podman.compose.config-hash=123 --label io.podman.compose.project=myservice --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=myservice --label com.docker.compose.project.working_dir=C:\Users\$USER\dev\docker\myservice --label com.docker.compose.project.config_files=compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=myservice --net myservice_default --network-alias myservice localhost/myservice
2b348b5132db227f6cd2e9bac34ce19949148a3cb471761517b4af9f95face27
exit code: 0
podman start -a myservice
!... Hello Podman World ...!
.--"--.
/ - - \
/ (O) (O) \
~~~| -=(,Y,)=- |
.---. /` \ |~~
~/ o o \~~~~.----. ~~
| =(X)= |~ / (O (O) \
~~~~~~~ ~| =(Y_)=- |
~~~~ ~~~| U |~~
Project: https://github.com/containers/podman
Website: https://podman.io
Documents: https://docs.podman.io
Twitter: @Podman_io
exit code: 0
```
**Environment:**
- OS: WSL
- podman version: 4.3.1
- podman compose version: 1.0.3
**Additional context**
`podman` is installed on Windows/WSL using Podman Desktop, with `podman-compose` installed using `pip3 install podman-compose`
Contributor guide
Assessment
This issue has not been assessed yet.