What is Dockerfile?

Published by Aryan on

Docker Container

Hello Folks!

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.

  • FROM
  • RUN
  • CMD
  • COPY
  • ADD
  • ENV
  • USER
  • ARG

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.

FROM ubuntu:bionic

Let us copy one file “hosts” file from current working directory to “/root/hosts” inside Docker.

FROM ubuntu:bionic
COPY hosts /root/hosts


Hey Friends, Thank you for visiting my blog and spending some of your precious time reading it. Myself Aryan who works with a variety of computer technologies. This blog is a write-up of my understanding of various topics after reading different materials about it. I hope that it helps you in some way. Enjoy reading and feel free to connect with me.


Leave a Reply

Your email address will not be published. Required fields are marked *