Docker

Docker becoming trend around this year and becoming standard on IT Industry for deployment of software applications.

I am also as developer but mostly on my previous job i couldnt learn this technology, because Sharepoint On-Premise currently not yet support on this Docker Environment.

After i joined this company Infinys System Indonesia https://infinyscloud.com/id, i have a lot learn about docker from team developer in here, because some deployment of our website it built on top of Docker.

The top reason enterprises are using Docker is to help them deploy across multiple systems, migrate applications, and remove manual reconfiguration work. Because application dependencies are built into containers, Docker containers significantly reduce interoperability concerns.

In this article, I’ll share what I have learned so far about docker.

  • What is docker?
  • Components of Docker
  • Comparison Virtual Machine vs Docker
  • When to use Container vs VMs
  • Basic Commands on Docker

A. What Is Docker

Docker delivers software in containers, which simplifies the process by packaging everything it takes to run an application.

There are numerous advantages to using containers to deploy applications.

  • Isolated — Applications have their own libraries; no conflicts will arise from different libraries in other applications.
  • Limited (limits on CPU/memory) — Applications may not hog resources from other applications.
  • Portable — The container contains everything it needs and is not tied to an OS or Cloud provider.
  • Lightweight — The kernel is shared, making it much smaller and faster than a full OS image.

B. Component Of Docker

  • Docker file is a text document that contains necessary commands which on execution helps assemble a Docker Image.
  • Docker Image it is a set of instructions which is used to build containers, consisting of application code with all the dependencies and libraries. It is portable so it can easily be shared between developers and operators.
  • Container is a way of packing application with all its dependencies and configuration files. A container is a running instance of our image.
  • Docker Engine supports the tasks and workflows involved to build, ship and run container-based applications. The engine creates a server-side daemon process that hosts images, containers, networks and storage volumes. Docker Engine is a client-server based application.
  • Docker CLI is a command line tool that lets you talk to the Docker daemon.

C. Comparision Virtual Machine vs Docker

Docker containers and virtual machines are both ways of deploying applications inside environments that are isolated from the underlying hardware. The chief difference is the level of isolation.

Link : https://www.weave.works/blog/a-practical-guide-to-choosing-between-docker-containers-and-vms

With a container runtime like Docker, your application is sandboxed inside of the isolation features that a container provides, but still shares the same kernel as other containers on the same host. As a result, processes running inside containers are visible from the host system (given enough privileges for listing all processes). For example, if you start a MongoDB container with Docker, then run ps -e | grep mongo in a regular shell on the host (not in Docker), the process will be visible. Having multiple containers share the same kernel allows the end user to bin-pack lots and lots of containers on the same machine with near-instant start time. Also, as a consequence of containers not needing to embed a full OS, they are very lightweight, commonly around 5-100 MB.

In contrast, with a virtual machine, everything running inside the VM is independent of the host operating system, or hypervisor. The virtual machine platform starts a process (called virtual machine monitor, or VMM) in order to manage the virtualization process for a specific VM, and the host system allocates some of its hardware resources to the VM. However, what’s fundamentally different with a VM is that at start time, it boots a new, dedicated kernel for this VM environment, and starts a (often rather large) set of operating system processes. This makes the size of the VM much larger than a typical container that only contains the application.

D. When to use Container vs VMs

Containers are a good choice for the majority of application workloads. Consider containers in particular if the following is a priority:

Start time
Docker containers typically start in a few seconds or less, whereas virtual machines can take minutes. Thus, workloads that need to start very quickly, or that involve spinning apps up and down constantly, may be a good fit for Docker.

Efficiency
Because Docker containers share many of their resources with the host system, they require fewer things to be installed in order to run. Compared to a virtual machine, a container typically takes up less space and consumes less RAM and CPU time. For this reason, you can often fit more applications on a single server using containers than you could by using virtual machines. Likewise, due to their lower levels of resource consumption, containers may help to save money on cloud computing costs.

Licensing
Most of the core technologies required to deploy Docker containers, including container runtimes and orchestrators like Kubernetes, are free and open source. This can lead to cost savings while also increasing flexibility. (But it’s worth noting that in many cases organizations will use a commercial distribution of Docker or Kubernetes in order to simplify deployment and obtain professional support services.)

Code reuse
Each running container is based on a container image, which contains the binaries and libraries that the container requires to run a given application. Container images are easy to build using Dockerfiles. They can be shared and reused using container registries, which are basically repositories that host container images. You can set up an internal registry to share and reuse containers within your company. Thousands of prebuilt images can be downloaded from public registries (e.g. Docker Hub or Quay.io) for free and used as the basis for building your own containerized applications.

Of course, VMs may be packaged into images, too, and those images can also be shared, but not as efficiently and easily as containers. Furthermore, virtual machine images aren’t as easy to automatically build, and are typically larger in size. Also, because they usually include operating systems, redistributing them can become legally complicated. (In most cases you can’t legally download and run a virtual machine image with Windows preinstalled without having a Windows license, for example.)

When to stick with virtual machines
Let’s look at some reasons why you might forgo Docker and stick with your virtual machines.

Security
A full discussion of the security merits of virtual machines as compared to Docker is beyond the scope of this article. But suffice it to say that, essentially, virtual machines are more isolated from each other and from the host system than are Docker containers. That is because virtual machines, as we’ve noted, don’t directly share any kernels or other resources with the host system.

For this reason, virtual machines are arguably more secure overall than containers. Although Docker provides various tools to help isolate containers and prevent a breach within one container from escalating into others, at the end of the day, containers aren’t isolated from a security perspective in the same way that virtual machines are.

E. Basic Commands on Docker

To get started using Docker, you have to download the Docker Application in this site https://www.docker.com/

Docker running smoothly on top OS Windows (Desktop / Server), Linux and also Mac OS.

After the installation Docker completed, it will appear UI like this below :

and you can as well using CLI to access the docker

For syntax and command on Docker, you can download this pdf file https://www.docker.com/sites/default/files/d8/2019-09/docker-cheat-sheet.pdf

  • docker pull pulls an image from registry to local machine.
  • docker images show images
  • docker run both creates and run a container in single operation
  • docker ps shows running containers
  • docker stop, stops a running container
  • docker ps -a shows running as well as stopped containers
  • docker start, starts a container to run it
  • etc

Happy Docker-ing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.