Introduction to Docker


  This entry is part 1 of 1 in the series Creating & Deploying a SpringBoot app in Docker


Welcome to the first part of this series. To understand rest of the series it’s essential to know the basics of Docker. So let’s get started.

Docker is an open platform for developing, shipping, and running applications.

Docker provides a way to run almost any application securely isolated in a container. The isolation and security allow you to run many containers simultaneously on your host. The lightweight nature of containers, which run without the extra load of a hypervisor, means you can get more out of your hardware.

These are the reasons it’s preferred platform for micro-services based applications.

Docker is based on the concept of Linux containers let’s have a look at Linux containers.

Linux containers

In a normal virtualized environment, one or more virtual machines run on top of a physical machine using a hypervisor like Xen, Hyper-V etc. Containers, on the other hand, run in user space on top of operating systems kernel.

Continue reading Introduction to Docker

GCD Of Two Numbers

Naive Algorithm

Function NaiveGCD(a, b)

best <- 0
for d from 1 to a+b:
    if d|a and d|b:
        best <- d
return best

  • Runtime approximately a+b
  • Very slow for 20 digit numbers

Python Implementation

def gcd(m, n):
    gc = 0
    for i in range(1, m+n):
        if m % i == 0 and n % i == 0:
            gc = i
    return gc

default_a = 3918848
default_b = 1653264

a = input("Enter a: [%s]" % default_a)
b = input("Enter b: [%s]" % default_b)

a = a or default_a
b = b or default_b

g = gcd(int(a), int(b))

print("GCD is: ", g)

Continue reading GCD Of Two Numbers