DEV Community

Cover image for Containers - Docker, Kubernetes and Cloud Buildpacks
Dhruvesh Patel
Dhruvesh Patel

Posted on

Containers - Docker, Kubernetes and Cloud Buildpacks

This post will focus on how to create containers using open source tools and technology - starting from Docker (tool designed to build, package, deploy, and run applications by using containers), Kubernetes (Container Orchestration tool) and Cloud-native Buildpacks (quickest way to turn app code into images that can run on any cloud).

Containers

Container is used to package and run an application on a shared Operating System. They are isolated from other Containers and share the resources of the underlying Operating System, allowing for efficient restart, scale-up or scale-out of applications across clouds. Containers typically contain Microservices.

Benefits of using Containers over traditional Virtual Machines such as,

  • Agility - Accelerate software development / deployment & Fast application start-up, as no OS to boot like VMs
  • Portability - Easy moving across environments as standardized packaging for software and its dependencies
  • Security - Built-in security capabilities
  • Cost Savings - Lightweight and consumes less computing resources (CPU, RAM, disk space)

Following diagram shows differences between VM and Containers.

VM vs Containers

What is Docker?

Docker is a popular open source platform with ecosystem of products that use containers, which allows to package and run application in an isolated environment.

Docker comes with eco-system of products like,

  • Docker Hub - hosted repository service for finding and sharing container images
  • Docker Engine - an open source containerization technology for building and containerizing your applications
  • Docker Desktop - enables you to start containerizing in minutes and is the easiest way to run Docker Engine on personal laptop

Docker collaborates with the open source ecosystem through an array of projects that continue to fuel the containerization movement, the Docker platform and other Docker products. For more details, Refer https://www.docker.com/community/open-source

Docker commands

Docker Build and Share Commands

Docker Run Commands

Sample Dockerfile for Java based Spring Boot Application:

Sample Dockerfile

Kubernetes

Kubernetes is a Container orchestration platform, which is portable, extensible, open-source platform for managing containerized workloads and services and facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem.

Following diagram shows different components of Kubernetes.

Kubernetes Components

Kubernetes provides ready-to-use functionality for below management tasks.

k8s management tasks

To get hands dirty with deploying containerized apps to Kubernetes, start with minikube, it helps to deploy Kubernetes locally.

Cloud Buildpacks

Cloud Native Buildpacks (https://buildpacks.io/) transform your application source code into images that can run on any cloud - without any hassle of knowing low level details of defining Dockerfile.

The fastest way to try Cloud Native Buildpacks is via the pack CLI from buildpacks. It helps to create a runnable app image from source code without writing Dockerfile.

In order to run the build process in an isolated fashion, pack uses Docker. Run following commands to build sample Java application image.

Buildpacks commands

That’s it! You’ve now got a runnable app image called myapp available on your local Docker daemon - in just under 100 seconds. Please note, that your app was built without needing to install a JDK, run Maven, or otherwise configure a build environment. Pack and buildpacks took care of that for you.

Happy coding and containerizing !! Please like, share and comment your views/ opinion.

Disclaimer - This post is my personal opinion and does not reflect those of any of my past, present or future employers or affiliations.

Top comments (12)

Collapse
 
prabhat36539454 profile image
Prabhat Kumar

Thanks for sharing.

Collapse
 
dhruvesh_patel profile image
Dhruvesh Patel

Hope you learnt a thing or two by reading this.

Collapse
 
shreya1310 profile image
Shreya1310

Really very happy to say,your post is very interesting to read. Can't wait to try this out in my next project.

Collapse
 
dhruvesh_patel profile image
Dhruvesh Patel

Thanks a lot, Keep learning something new every day.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.