When I repeatedly attempt to build an image, it always assembles it without using any cached layer. I tried various options (nocache=False, layers=True etc.) but was unsuccessful.
My Dockerfile/Containerfile looks for example like this:
FROM docker.io/library/fedora:latest
RUN dnf update -y
RUN echo 'Hey'
Building the image using this library always re-executes all the steps:
import podman
client = podman.PodmanClient(base_url="unix:///tmp/podman.sock")
print(client.version())
image, logs = client.images.build(
dockerfile="Dockerfile",
tag="localhost/test-podman",
path="src/",
rm=False,
)
for log in logs:
print(log)
However if I use the docker library instead, it uses caches:
import docker
client = docker.DockerClient(base_url='unix:///tmp/podman.sock')
print(client.version())
image, logs = client.images.build(
dockerfile="Dockerfile",
tag="localhost/test-docker",
path="src/",
rm=False,
)
for log in logs:
print(log)
I'm experiencing this issue with podman version 5.2.2 (on Alma Linux 9), version 4.9.3 (Ubuntu 24.04 in WSL), version 5.4.1 (on mac OS).
$ time python run-podman.py
real 0m11.543s
user 0m0.118s
sys 0m0.027s
$ time python run-podman.py
real 0m12.186s
user 0m0.109s
sys 0m0.033s
$ time python run-docker.py
real 0m12.512s
user 0m0.147s
sys 0m0.011s
$ time python run-docker.py
real 0m0.323s
user 0m0.132s
sys 0m0.000s
When I repeatedly attempt to build an image, it always assembles it without using any cached layer. I tried various options (
nocache=False,layers=Trueetc.) but was unsuccessful.My Dockerfile/Containerfile looks for example like this:
Building the image using this library always re-executes all the steps:
However if I use the docker library instead, it uses caches:
I'm experiencing this issue with podman version 5.2.2 (on Alma Linux 9), version 4.9.3 (Ubuntu 24.04 in WSL), version 5.4.1 (on mac OS).