Docker in 5 Minutes

What is Docker?

  1. Docker is an open platform for developing, shipping, and running applications.
  2. It enables us to separate applications from the infrastructure so anyone can deliver software quickly.

Why Docker?

In a nutshell: Write Code Once -> Create Docker Container -> Run Anywhere

  1. Anyone write code locally and share their work with anyone using Docker containers.
  2. They can use Docker to push their applications into a test environment and can execute automated or manual tests.
  3. When testing is complete, getting the fix (For e.g. to the customer) is as simple as pushing the updated image to the production environment.

How Docker Works ?

  1. Docker provides the ability to package and run an application in a loosely isolated environment called a container.
  2. The isolation and security allow us to run many containers simultaneously on a single host.

Sounds Interesting but how does it differ from Virtual Machines ?

Some advantages of Docker Containers over Virtual Machines

  • Fast Execution Speed
  • Low RAM and Drive memory usage
  • Very Fast Startup Time (generally in milliseconds 🙂

Dockerfile, Image & Container

  • A Docker Image is basically a set of rules or template for creating an environment
  • We can create docker images using Dockerfile
  • Dockerfile is basically a text file containing a set of instructions for creating the Image
  • A Docker Container is basically a running instance of an Image

Enough Talk… Lets Create some Conatiners

Python Hello World inside a Docker Container

  • For this I have created a python file ‘’ which contain a print statement.
  • Under Simple Tags section, we can see different types of versions & flavours of python image available. We will we using 3.8-alpine since alpine’s images are very less in size.

Step 1. Lets create a Dockerfile

  • I have created a simple file named Dockerfile, with the following content
  • WORKDIR is basically our working directory inside the image. It is similar to cd(change directory command) in Linux / Windows.
  • COPY command is use to copy files/folders inside the image
  • CMD is used to run any command in the container’s terminal.

Step 2. Building the Image

The command to build the above dockerfile is

docker build -t python_hello .

  • -t : specifies the name of image (python_hello)
  • .’ : is the location of dockerfile

Step 3. Lets Run the Container

The Command is

docker run python_hello

Here is the output we got. The container starts, executed our command and exited.

Some More Examples of Dockerfile

  1. Creating an Apache HTTP Server
  • Dockerfile (Expose 80 tell the container to listen on port 80 (default HTTP port))
  • Build using docker build -t apache-httpd
  • Run using docker run -p 8080:80 apache-httpd
  • -p 8080:80 forwards the 80 port inside the container to 8080 port on Host machine
  • Result

Congratulation on sucessfully building your docker container & Thanks for sticking till the end.

Please let me know about your views or queries in the comment section.

Image Source


Docker in 5 Minutes was originally published in The Startup on Medium, where people are continuing the conversation by highlighting and responding to this story.

Related Articles

This Mac app lets you copy-paste texts from images

Sometimes I want to copy a couple of sentences from a document to get a list from the website for your personal reference, but can’t do so because of restrictions on the text. Thankfully, I came across TextSniper — a Mac app that lets you extract text from non-selectable sources such as YouTube videos, PDFs, photos, or presentations. Getting text out of a document or a photo is pretty simple. Once you instal TextSniper on your Mac, you need to define the invoke command shortcut. Whenever you press that, you’ll activate the tool, and then you just have to select… This story continues at The Next Web

How To Port Your Web App To Microsoft Teams

On your list of places where people might access your web app, “Microsoft Teams” is probably number “not-on-the-list”. But it turns out that making your application accessible where your users are already working has some profound benefits. In this article, we’ll look at how Microsoft Teams makes web apps a first-class citizen, and how it enables you to interact with those apps in completely new ways. 


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

Receive the latest news

Subscribe To Our Weekly Newsletter

Get notified about chronicles from TreatMyBrand directly in your inbox