Introduction to Docker for DevOps

Introduction to Docker for DevOps

A Little Bit of Container History

Docker is a container runtime. A lot of people think that Docker was the first of its kind, but this is not true – Linux containers have existed since the 1970s.

Docker is important to both the development community and container community because it made using containers so easy that everyone started doing it.

What are containers?

Containers, or Linux Containers, are a technology that allows us to isolate certain kernel processes and trick them into thinking they're the only ones running in a completely new computer.

Different from Virtual Machines, a container can share the kernel of the operating system while only having their different binaries/libraries loaded with them.

In other words, you don't need to have a whole different OS (called guest OS) installed inside your host OS. You can have several containers running within a single OS without having several different guest OS's installed.

What is Docker?

Docker is free software developed by Docker Inc. It was presented to the general public on March 13, 2013, and has become since that day a must in the world of IT development.

It allows users to create independent and isolated environments to launch and deploy their applications. These environments are then called containers.

This will let the developer run a container on any machine.

As you can see, with Docker, there are no more dependency or compilation problems. All you have to do is launch your container, and your application will launch immediately.

But, is Docker a virtual machine?

Here is one of the most asked questions about Docker. The answer is: actually, not quite.

It may look like a virtual machine at first, but the functionality is not the same.

Unlike Docker, a virtual machine will include a complete operating system. It will work independently and act like a computer.

Docker will only share the resources of the host machine to run its environments.

Why use Docker as a developer?

Docker is fast. Unlike a virtual machine, your application can start in a few seconds and stop just as quickly.

Docker is multi-platform. You can launch your container on any system.

  • Containers can be built and destroyed faster than a virtual machine.

  • No more difficulties in setting up your working environment. Once your Docker is configured, you will never have to reinstall your dependencies manually again. If you change computers or if an employee joins your company, you only have to give them your configuration.

  • You keep your work space clean, as each of your environments will be isolated and you can delete them at any time without impacting the rest.

  • It will be easier to deploy your project on your server to put it online.

Dockerfile, Images & Containers

Dockerfile, Docker Images & Docker Containers are three important terms that you need to understand while using Docker.

Dockerfile:

A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

The specific commands you can use in a dockerfile are:

FROM, PULL, RUN, and CMD

  • FROM - Creates a layer from the ubuntu:18.04

  • PULL - Adds files from your Docker repository

  • RUN - Builds your container

  • CMD - Specifies what command to run within the container

Docker image:

A Docker image is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform. It provides a convenient way to package up applications and preconfigured server environments, which you can use for your own private use or share publicly with other Docker users.

Docker Images are stored in the Docker Registry. It can be either a user’s local repository or a public repository like a Docker Hub which allows multiple users to collaborate in building an application.

Docker Container:

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

Docker Compose & Docker Swarm

Docker Compose is a YAML file which contains details about the services, networks, and volumes for setting up the application. So, you can use Docker Compose to create separate containers, host them and get them to communicate with each other. Each container will expose a port for communicating with other containers.

Docker Swarm is a technique to create and maintain a cluster of Docker Engines. The Docker engines can be hosted on different nodes, and these nodes, which are in remote locations, form a Cluster when connected in Swarm mode.

Conclusion:

Docker is a revolutionary technology that simplifies isolation and provides environment independency. However, in its current shape, you should only use it in development and testing environments.


Thanks for reading to the end; I hope you gained some knowledge.❤️🙌

PARAMVEER SINGH