The Dockerfile is a text-based build instruction file that enables us to define the content of the Docker image and automate image creation. The Docker build engine reads the instruction in the Dockerfile line by line and constructs the image as prescribed. In other words, Dockerfile helps us to craft an image repeatedly in an automated fashion. The images created using Dockerfiles are considered immutable.
Building an image using a Dockerfile
Getting ready
Before we begin, we need a Dockerfile with build instructions. To make one, we need to go through the following steps:
- Create an empty directory:
$ mkdir sample_image $ cd sample_image
- Create a file named Dockerfile with the following content:
...