It’s about docker!!!

Life becomes easier using this whale carrying your images

Confused but still, want to speak about docker and how it makes the life easier for a developer so let’s begin…!!

What is docker?

If you're working with setting up a dev environment or try to deploy to production, then you might have come across the term “Docker” via search or suggested with a solution that is to use “Docker”.

According to the official site, Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. In simple terms, Docker is a software that makes it possible to have a copy of os run in isolation on your machine. It is something similar to a virtual machine but things that are associated with docker and how they work is different.

How Do Dockers Work?

For running an external os on your host machine you need to set up a virtual machine, dual boot it or to use tools that will rather make a virtualization process automated and sharable. Here Docker does the same thing but it doesn’t need another OS installed, instead it uses the host OS. That is, OS with which our host machine is running with the docker isolates the network, space, and processes. So the use of docker remove the additional processes such as the no OS set up and boot up the process. This makes to run our application faster without the additional dependencies applied. As these processes or the machines that are created on the host machines are called as the images. We will discuss a bit more about this pretty soon.

Advantages of Dockers:

  1. Fast deployment of new services with limited memory and performance resources.
  2. Accelerated software development and deployment.
  3. A simple approach to app functionality scaling.
  4. The simple approach to app functionality scaling.
  5. High accessibility.
  6. Decreased downtimes.

Disadvantages of Dockers:

Before the employment of the software the most common thing that the developer’s point is related to the vulnerability of the target software. For example, If we are providing access to the container through web servers that is with the help of an API, we should thoroughly think about the parameter verification process such that their hackers don’t pass change the data with the request which might provoke further generation of new images or containers.

Let's get started with a simple example:

In this, we go through simple steps of how to work with dockers. Before getting started you should have docker on your machine. Installing docker using binaries go here and follow the instructions to set it up. You can check if the installation was successful from your terminal using a command “ docker -v” to display the version of Docker you have installed.

After the successful installation of the dockers, let's try to work with the few commands of docker.

Example:

Ghost is an open source blogging engine that has gained popularity. But to run this it requires that you need to install node and a ton of other related dependencies which might consume a lot of time and sometimes we might also few commands to be played with. To do this in a docker way we simply run.

$ docker pull ghost

This pulls the ghost setup onto your host machine and this is known as IMAGE.

After the pull of the ghost rather this might take some time as it depends on your internet speed, you can view the list of images you have with

$ docker images

Next step after listing your images, is to run a container from the image we just pulled. The concept between containers and images is usually confusing. let us understand in similar terms, An instance of an image is called a container. You have an image, which is a set of layers as you describe. If you start this image, you have a running container of this image. You can have many running containers of the same image. I guess this might helped you know the difference between containers and images. So let us go ahead and run a container from our image.

$ docker run --name ghost_article -p 8080:2368 -d ghost

This will run a container on port 8080. You can access the ghost on http://localhost:8080

Let us take a look at the command that made to run the container.

$ docker run

This command is used to run a container from an image. The next point is about

$ -p 8080:2368

This maps port 8080 of your machine to the port 2368 within the container which is why accessed container using http://localhost:8080

We can also list all the container that is running with the command

$ docker ps

So the process of installing a huge bundle and going through each installing methods are reduced through docker and it acts as an excellent way to distribute software.

You can find docker images of the most popular software from the Docker hub or the docker store.

Some of the commands to get familiar

$ docker exec -i -t <container_id> /bin/bash

With this, you can get access to the container. You can find the container id with the command docker ps.

$ docker stop <contianer_id>

The command docker stop with container id it stops the container. Once the container is stopped the command “docker ps” doesn't list out so with the command docker ps we should add a flag “-a” to list stopped containers.

$ docker ps -a

To start the stopped container we can use the command

$ docker start <container_id>

There are many things that can be handled working with Docker. With dockers, we can also commit the state of the container to an image and share the same state of running container or software with others also.

Docker is also available with some of the visual tools like Portainer which provide the insights of the docker files associated with you.

Technically, This article gives you the insight of introduction to docker and its use-cases. Hope you have drawn some knowledge from this article.