What is docker and how is related to devops?
What is docker?
What is docker?
When we talk about docker and kubernetes it is a necessity for a lot of developers who are looking for a standard way to build and share applications. If you’ve done any development for a fullstack application, you’ll know that for example,to build a django application(which needs python to be installed on your OS) you’re potentially going to need a database, so you install a database onto your operating system maybe mysql or postgres database. Nginx(server), celery,rabbitmq or redis(for a message broker) might be needed for your application. While the application grows, more packages might be needed. If you're working with a team of developers, there are a couple of problems you might encounter (different development software versions, different operating systems) and creating a replica of certain issues can be very difficult while developing.
One way we can solve this is by using Virtualization. Virtualization allows us to create containers on our operating system through which another operating system can be installed. We can have multiple operating systems running on our own machine. Basically, it allows us to create a virtual of an operating system, server or a storage device. We could create a virtual machine, Install the various softwares and packages needed for development, then give access to developers on our team.
Docker is a virtualization apparatus that encourages us to make containers and manage them efficiently. These containers can house different packages and with the help of docker, they can communicate with each other which leads to an increase in development time. One great thing about docker is that it isn’t specifically for one operating system, meaning we can give containers to other devs on the team that do not have the same operating systems.
Docker’s website offers a great point to start from, signup with a unique username and login.
After logging in, we can create a repository for our containers.
What is a Docker Container, Image, Layer.
Docker allows us to build, ship and run software in any location that has Docker. Today we learn about Docker Containers, Images and Layers.
A Container is an enclosure for holding product or package. Containers could be build and shared among other developers to ensure conformity in software packages or package version, dependencies or base OS. Layers provide better consistency and a way of sharing and developing software in a more controlled state. In more complex terms Containers provide elastic scalability, individual isolation and portability, better consistency. A Docker Container is OS independent. To understand a Container further we need to focus on Images and Layers, and know the connections between them and how they relate to each other
One can say to build an image, multiple layers(for example an operating system later) are used. This means multiple layers are in an image, in simple terms. Then Docker runs this image. a Docker Container can be viewed as a Docker image in execution: when an image is run by Docker, we call it a container.
So the question arises, How is an image created? One way would be to use docker commands to build an image by hand(docker run). Another approach would be to build from an existing image or from a base image. This way we can download or extend the original image if required. To create an image, also we can use a Docker file Configuration Management tool(CM tool) to collect an existing docker file or docker image then utilize different CM tools to configure it to what we desire. You can also build an image from scratch by using and existing or blank image then importing a set of files to that image then run it as a container. In summary, an image is a collection of file system layers and Metadata, say for example installing a MySQL separate file system layer and a Linux OS, next these layers are run by Docker as a container. Generally, we build images then run these images as containers.
To validate containers, or to point out the relation of images and containers, a container can be seen as a running instance of an image. It is possible to run multiple containers from the same image without altering the image integrity, so that the original image would not get changed by each container.
Layers
From what has been explained so far, Layers are softwares inside our image. Layers can be seen as shared libraries. This means that layers can be shared across multiple running containers making it easy to scale up and also running multiple instances. A benefit of layers would be its copy-on-write mechanism: This implies that when we use a layer, alterations and changed made are stored as extensions to that particular layer in the image. When a new person intends to use these layers, whatever changes he makes are stored as extensions to the original file instead of creating a brand new copy of the base layer. This helps to reduce amount of disk space required and it also overcomes scalability issues.
Docker in your Window
Docker can be used to deploy and develop applications, create consistent environments in terms of software packages and dependencies and version control of software and allows developers to be working from the same versions in the same software. Docker allows sharing of environments and provides flexibility for example when prototyping software and when debugging environments. Docker tools can be used when building an application where updates are constantly required and upgrading needs to be done. To deploy our app, it would be case of moving our image across to a server and the let it run as a container.
Conclusion:
Docker containers are portable, can be easily shared and don’t run the OS but they rely on the host’s kernel. The only processes running in the container are the ones your software needs, which makes it lighter than virtual machines.