Understanding Dockerfiles, components, and directives
A Dockerfile is a simple file that constitutes a series of steps needed to build a Docker image. Each step is known as a directive, and there are different kinds of directives. Let's look at a simple example to understand how it works.
We will create a simple NGINX container, but this time by building the image from scratch and not using the one available on Docker Hub.
So, start by creating a Dockerfile, as follows:
$ vim Dockerfile FROM ubuntu:xenial RUN apt update && apt install -y curl RUN apt update && apt install -y nginx CMD ["nginx", "-g", "daemon off;"]
Let's look at each line and directive one by one to understand how this Dockerfile works: