Pattern: Missing use of --no-cache
switch
Issue: -
As of Alpine Linux 3.3 there exists a new --no-cache
option for apk
. It allows users to install packages with an index that is updated and used on-the-fly and not cached locally. This avoids the need to use --update
and remove /var/cache/apk/*
when done installing packages.
Example of incorrect code:
FROM alpine:3.7
RUN apk update \
&& apk add foo=1.0 \
&& rm -rf /var/cache/apk/*
FROM alpine:3.7
RUN apk add --update foo=1.0
&& rm -rf /var/cache/apk/*
Example of correct code:
FROM alpine:3.7
RUN apk --no-cache add foo=1.0