Creating a Docker image from Dockerfile

Our next step is to create a sample image file. We can build a Docker image using a Dockerfile. It provides step-by-step instructions to building images.

Let's try with a simple CentOS image:

  1. The Dockerfile contains the following two lines:
            FROM centos 
            MAINTAINER mitesh <mitesh.soxxxxxx@xxxxxxxx.com>
    
  2. Go to the same directory in the terminal and use docker build .to build an image:
                [root@localhost Desktop]# docker build .
                Sending build context to Docker daemon 681.6 MB
                Sending build context to Docker daemon 
                Step 0 : FROM centos
                 ---> 2a332da70fd1
                Step 1 : MAINTAINER mitesh < mitesh.soxxxxxx@xxxxxxxx.com >
                 ---> Running in 305e8da05500 ...

Get DevOps for Web Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.