Docker Image and Container — Beginner Level
Docker enables developers to easily pack, ship, and run any application as a lightweight, portable, self-sufficient container, which can run virtually anywhere. … Containers do this by enabling developers to isolate code into a single container. This makes it easier to modify and update the program
Lets start by defining a docker file. It is a simple file which includes details about base image, dependencies and command line argument (if needed).The below docker file is to create simple python based docker image.
The first line denoted the base image I am using to create docker. And then I am copying all the files and folder from my current directory to docker pod.Just to be clear, the folder structure is as shown below.
cmd.py is a simple python script to print “Hello World” with a help of flask framework. The text file requirement.txt includes all the necessary libraries I need to run the script. From the .py file it is very evident that I need only “flask”, hence I can replace the fourth line of dockerfile with “RUN pip install flask”. 🙏
Now lets launch Docker to create an image!