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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.