In Dockerfiles, when commands within a RUN instruction have a lot of arguments, especially those that install system packages, it is
important to ensure that the arguments are sorted alphabetically (if the order is not enforced by a command). This practice enhances the readability
and maintainability of the code. It allows for easier tracking of modifications and can help prevent potential errors.
When arguments in RUN instructions are not sorted alphabetically, it can make the Dockerfile harder to read and maintain. However,
when arguments are sorted, it is easier to track changes in version control systems and to locate specific arguments. This applies first and foremost
to package managers, where a list of installed packages can grow over time.
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
unzip \
wget \
curl \
git \
zip
FROM alpine:3.12 RUN apk add unzip wget curl git zip
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y \
curl \
git \
unzip \
wget \
zip
FROM alpine:3.12 RUN apk add curl git unzip wget zip