0

I'm a newbie to the containerization environment and I'm starting to build container images with buildah tool but it's hard to understand the cache layer while creating images. Could someone help me clarify?

I build images with simple docker file as:

FROM docker.io/library/alpine as downloader
USER root
RUN touch /tmp/hello.txt

FROM docker.io/library/fedora
ENV foo=bar
RUN mkdir blah
COPY --from=downloader /tmp/hello.txt /blah/

The first one i try to with --layers option, Caching will be used instead of building new:

cmd: buildah bud --layers -f Dockerfile .
STEP 1: FROM docker.io/library/alpine AS downloader
STEP 2: USER root
--> Using cache 532252175243c24d52fdd0ee508d8e37ca64082e3547d531773ea195df567201
STEP 3: RUN touch /tmp/hello.txt
--> Using cache 40811fe6bc8e50fca9287bdbd841259dc1536a7bfbcd5bcf22935acfc88752a0
STEP 4: FROM docker.io/library/fedora
STEP 5: ENV foo=bar
--> Using cache b364a92d2918c2967072154500df94410c04a41cdfd080409afcb344eb331c88
STEP 6: RUN mkdir blah
--> Using cache e095949ceaf95f93dfa874b1919ae3e0571cc800c5740a779623f5f5e8d63b6c
STEP 7: COPY --from=downloader /tmp/hello.txt /blah/
--> Using cache 57ec2b918030cf2819de3277c6c56d3f3031eaa0a777d1bc530730797a6a0098

Second, I try with --no-cache option:

cmd: buildah bud --no-cache -f Dockerfile .
STEP 1: FROM docker.io/library/alpine AS downloader
STEP 2: USER root
STEP 3: RUN touch /tmp/hello.txt
STEP 4: FROM docker.io/library/fedora
STEP 5: ENV foo=bar
STEP 6: RUN mkdir blah
STEP 7: COPY --from=downloader /tmp/hello.txt /blah/
STEP 8: COMMIT
0c6ef582c048279a07d22853e150acfa86204785a0428c42c1d86727a37ccb35

==> Cache is not used and the COMMIT step is generated automatically by buildah tool

Finally, I tried without --layers and --no-cache options:

cmd: buildah bud -f Dockerfile .

STEP 1: FROM docker.io/library/alpine AS downloader
STEP 2: USER root
STEP 3: RUN touch /tmp/hello.txt
STEP 4: FROM docker.io/library/fedora
STEP 5: ENV foo=bar
STEP 6: RUN mkdir blah
STEP 7: COPY --from=downloader /tmp/hello.txt /blah/
STEP 8: COMMIT
Getting image source signatures
Copying blob 811f92a7a340 skipped: already exists
Copying blob 5ad2f740e5d2 done
Copying config 1c0fa8762d done
Writing manifest to image destination
Storing signatures
1c0fa8762d23aa73a4a9d54d33c4527d91bee51cf7c202d9922a70a6dd889a13

==> Cache is not used and the COMMIT step is generated automatically but with more logs

I can not distinguish between the --no-cache and without the --no-cache option, and when the --no-cache option is not present why it is not re-use cache? One more question, why does the COMMIT step appear although the Dockerfile is not included?

0 Answers0