How to install packages in Dockerfile

Categories:

Debian and Ubuntu

Dockerfile
1RUN set -eu;\
2    export DEBIAN_FRONTEND='noninteractive';\
3    apt-get update; apt-get -y upgrade;\
4    apt-get -y install --no-install-recommends $packages;\
5    rm -rf /var/cache/* /var/log/* /var/lib/apt/lists/* /tmp/*

Alpine

Dockerfile
1RUN apk add --no-cache $packages

Documentation