Understanding Dockerfiles, components, and directives
A Dockerfile is a simple file that constitutes a series of steps to build a Docker image. Each step is known as a directive. There are different kinds of directives. Let’s look at a simple example to understand how this works.
We will create a simple NGINX container by building the image from scratch rather than using the one available on Docker Hub. NGINX is very popular web server software that you can use for a variety of applications; for example, it can serve as a load balancer or a reverse proxy.
Start by creating a Dockerfile:
$ vim Dockerfile FROM ubuntu:bionic 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:
- The
FROM
directive specifies what the base image for this container should be. This means...