This is yet another article to understand a new concept of Docker. There is a special file called as Dockerfile.
What is Dockerfile?
Dockerfile is a file that contains instructions to build an image. Instructions are a series of commands that you will otherwise run in running container and then commit it as an image.
Generally dockerfile is kept in a directory that is your current working directory. This directory should contain the files or directories that are to be copied to Docker image when we build it. Though, a dockerfile can reside at any other location as well.
There is defined list of instructions supported by Dockerfile. Following is the entire list.
Example of Dockerfile
Let us write one dockerfile with some routine operations. This will help us to understand meaning of some instructions listed above.
Any dockerfile should begin with FROM instruction. This will initialize our new image from a base image selected with FROM.
Let us copy one file “hosts” file from current working directory to “/root/hosts” inside Docker.
FROM ubuntu:bionic COPY hosts /root/hosts