APK ignores tmpfs but does it also ignore overlayfs? Having issues with installing packages in docker with `apk --no-network`
APK ignores tmpfs. I'm trying to build an alpine container using a new docker feature RUN --mount=
and in my case I'm trying to cache some apk packages in an image but I'm having some trouble using the cache to install packages with --no-network
later.
This part is successful:
# syntax=docker/dockerfile:1.4
FROM alpine:3.16 AS cache-prep
RUN mkdir /etc/apk/cache \
&& apk --update add busybox==1.35.0-r17 \
&& apk cache sync
FROM scratch AS cache
COPY --link --from=cache-prep /etc/apk/cache /
I can do docker build --target cache -t my-cache-image:test .
and the image is created with the /etc/apk/cache directory having the repo index and the apk files.
However, as mentioned, when I try to use the image later as a cache to install some packages with apk --no-network add
, I'm unable to:
# syntax=docker/dockerfile:1.4
FROM alpine:3.16 AS image
ARG TARGETARCH
RUN --mount=from=my-cache-image:test,id=apk-${TARGETARCH},sharing=locked,target=/etc/apk/cache,type=cache \
apk --no-network add \
busybox==1.35.0-r17
When I try to build this image, I get the output below:
> [image 1/1] RUN --mount=from=my-cache-image:test,id=apk-${TARGETARCH},sharing=locked,target=/etc/apk/cache,type=cache apk --no-network add busybox=="1.35.0-r17":
#11 0.186 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.16/main: No such file or directory
#11 0.186 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.16/community: No such file or directory
#11 0.186 ERROR: unable to select packages:
#11 0.186 busybox-1.35.0-r13:
#11 0.187 breaks: world[busybox=1.35.0-r17]
#11 0.187 satisfies: alpine-baselayout-3.2.0-r20[/bin/sh]
I can only imagine that apk is not seeing this cache directory because it's present on a cache mount (fstype=overlayfs). When I ran the mount
command inside the build context, I got the below as output for the filesystem type of the /etc/apk/cache mount, so I wanted to check if overlayfs is treated as a tmpfs, or if I am doing something wrong.