Dockerfile

Dockerfile

This article is the knowledge acquired on creating a simple Dockerfile as part of IIEC Rise 1.0 campaign under the mentorship of Vimal Daga Sir.

In this session we would be understanding the present scenario in container world where we run some additional softwares inside containers and also the steps to automate this.

Present scenario:

Consider the example, where we want to run python inside a container. For this, we require a base OS and then on top of this, we would run python program.

Conventional method to achieve this:

  • Pull the latest image of BaseOS from docker hub. Here we selected CentOS.
No alt text provided for this image
  • Run this CentOSimage to start a container. os1 is the name of the container.
No alt text provided for this image


  • As CentOS comes with yum preconfigured, use it to install Python.
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Now run command "python3".

No alt text provided for this image


Observing the above process closely we can see that,

1. We have used image FROM CentOS, and then created a container using this image.

2. RUN a command "yum install python36" to install python3.6 inside this container.

If we need to have multiple containers ( which run CentOS and Python36 inside ) then the above architecture would be a time consuming process. Instead of following above process we can simple create a custom image which has CentOS as Base operating system and also has Python36 installed in it.

What is Docker file..?

Dockerfile is one of the way to create a custom image. Technically it's a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build (which executes the Dockerfile), users can create an automated build that executes several command-line instructions in succession.

Note: The alphabet 'D' in Dockerfile should be in uppercase.

How to create Docker file..?

No alt text provided for this image


Add below content inside Dockerfile.

No alt text provided for this image

Keywords in Dockerfile

  1. FROM will indicate from which image the base OS will run.
  2. RUN will indicate the commands to be run inside the container.


Now the Dockerfile is ready to be build.

Use command, docker build -t <image_name> : <tag_name>

Here we have used rise as image name and v1 as tag

No alt text provided for this image
No alt text provided for this image

Now we can see the rise image has been successfully created.

No alt text provided for this image

Now we can utilise this image and launch containers.

No alt text provided for this image



要查看或添加评论,请登录

Zaheer Abbas的更多文章

  • Docker and HTTPD configuration using Ansible Automation

    Docker and HTTPD configuration using Ansible Automation

    #Task - 1: Write an Ansible PlayBook that does the following operations in the managed nodes: ?? Configure Docker ??…

  • Wonderful Journey of DO280 Training

    Wonderful Journey of DO280 Training

    Official RedHat OpenShift Administration I Training under guidance of World Record Holder Mr. Vimal Daga Throughout…

  • HTTP Archive files - Defect Logging

    HTTP Archive files - Defect Logging

    In the conventional testing, QA when reporting the defects utilize the classical method of giving data and some of the…

    3 条评论
  • Getting started with OpenShift 4.2

    Getting started with OpenShift 4.2

    Things learnt on Day-1 of Red Hat OpenShift (DO-280) instructor led training by Vimal Daga. Scenario: In today's…

  • Extent Reports4 Releasing soon

    Extent Reports4 Releasing soon

    For more details and features included in it, refer to https://extentreports.com/extent-framework-version-4-announcement/

社区洞察

其他会员也浏览了