The RUN keyword

The next important keyword is RUN. The argument for RUN is any valid Linux command, such as the following:

RUN yum install -y wget

The preceding command is using the yum CentOS package manager to install the wget package into the running container. This assumes that our base image is CentOS or Red Hat Enterprise Linux (RHEL). If we had Ubuntu as our base image, then the command would look similar to the following:

RUN apt-get update && apt-get install -y wget

It would look like this because Ubuntu uses apt-get as a package manager. Similarly, we could define a line with RUN, like this:

RUN mkdir -p /app && cd /app

We could also do this:

RUN tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz

Here, the former creates ...

Get Learn Docker - Fundamentals of Docker 19.x - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.