RUN command

A Dockerfile usually has more than one RUN command as part of it. These are intended to be executed as part of the system bash commands and are mainly used to install packages. For example, the following RUN command is used to install Java 8:

RUN    
echo oracle-java8-installer shared/accepted-oracle-license-v1-1
select true | debconf-set-selections &&
add-apt-repository -y ppa:webupd8team/java &&
apt-get update &&
apt-get install -y oracle-java8-installer &&
rm -rf /var/lib/apt/lists/* &&
rm -rf /var/cache/oracle-jdk8-installer

The preceding command was taken from the Dockerfile provided by an image called oracle-java8 (https://github.com/dockerfile/java/blob/master/oracle-java8/Dockerfile).

This command is easy to read, and each line describes how the installation process is done. The last two lines remove some directories from the container because they are no longer needed.

All installations are done as a single line because every RUN command generates a new layer. For example, in the RUN command, we can see that six instructions are executed at once. If we run those instructions one by one, we will end up having six images, each of which contains the base image plus the RUN command that was executed. We will not discuss layers in detail in this book, but if you feel curious, I highly encourage you to read about them at https://docs.docker.com/storage/storagedriver/#images-and-layers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.213.44