Container Management Platforms

This blog post will talk about containers & different container platforms available (mainly Kubernetes & docker swarm).

What is docker?

I have already talked about what docker is in one of my post:- Docker Basics but to give you a refresh -> Docker is a tool that helps you create, build and deploy applications regardless of the machine.

Thanks to the container based application running which allows developer/dev-ops to package the entire application as one including all the libraries and dependencies & deliver it as one package which can run on any machine.

What is the role of containers?

Containers allow the application to be packaged into one which facilitates for quick deployment & scalability amongst other benefits.

screen shot 2019-01-29 at 20.52.40

With docker – we can create and distribute containerized application but with lots of container up and running

  • how do we manage all the different containers?
  • how to scale container instances?
  • how can different container of my application communicate with each other

Kubernetes, Dockerswarm & Mesos are some of the solutions to these problems listed above which are in other words container management platform!

While Docker swarm is docker’s own container management solution whilst Kubernetes originally started at Google & is now open source.

Kubernetes & Docker Swarm

According to Kubernetes website: “Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.”

In other words, when an application containing several micro services is deployed across different containers on different machines. There is definitely a need to manage the containers which is possible through Kubernetes.

while on the other hand

Docker Swarm is Docker’s own solution for management of docker containers. It monitors the different containers spread across different servers. It provides a useful orchestration system which is well suited for the Dockerized apps.

screen shot 2019-01-29 at 22.03.23

Keep in mind docker swarm does not have much experience when it is production deployments at scale in comparison with Kubernetes. In the coming blogs, we will be covering about Docker Swarm and Kubernetes in detail. So stay tuned 🙂

 

 

 

Docker for Developers

What is Docker?

Docker is a tool that is made to create, deploy and run applications by using containers where Containers allow a developer to package its application (libraries, dependencies etc)  and deliver as one package. This package would eventually then run on any machine system regardless of the configuration that different machines may have.

What is a Docker Container?

Docker containers are based on Docker images. Docker image is thus a binary which includes all the information for running a single container. Each image has a unique id and these docker images can be stored/retrieved in/from docker registry. A docker registry contains docker image repositories and each repository can have one or more docker images. The official registry provided by Docker is Docker Hub.  The difference between docker container, image and registry is shown through this figure (Image taken from docs.openshift.com) :

Screen Shot 2017-08-20 at 18.09.40.png

My Spring Boot Rest Api project on GitHub can be run using Docker and all the below explanation of images, containers would have reference to this project. Information on how to build the Docker file can be checked in README file of my GitHub project.

Docker images

Building a Docker Image:

Docker image is built from a docker file. Once the docker file is built (docker file example) then a docker build command would be executed at the location where docker file is present in order to build the image.

      docker build -t <name of the docker image> .

For example, we run the command “docker build -t spring1.2 .” and upon success, below screenshot shows what message should appear.

Screen Shot 2017-08-20 at 18.19.09.png

Listing Docker Images created:

docker images

The image id associated with the image can also be determined using the command docker images. An image can be removed using its id. The below figure shows the different images that have been created with their image ids.

Screen Shot 2017-08-20 at 18.23.02.png

Removing a Docker image:

docker rmi <image id>

Docker image can be removed easily if its not yet associated to any container using the command mentioned above. However if it is associated to a container then first container needs to be removed using docker rm <container id> and then the image needs to be removed using docker rmi <imageid>

Docker containers

Running a docker container:

Docker image once built successfully implies a docker container can be run and the command to do the same is as follows:

For example: A spring boot application which needs to run on port 8080 and the name of the docker image is spring1.2 then docker container can be run using

docker run -p 8080:8080 -t spring1.2

Screen Shot 2017-08-20 at 18.31.49.png

Show currently running containers:

docker ps

Screen Shot 2017-08-20 at 18.34.38

Removing a docker container: 

docker rm <docker container id>