This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

D

DevOps

DevOps is not a goal, but a never-ending process of continual improvement

- Jez Humble, Site Reliability Engineering at Google Cloud, co-author of The DevOps Handbook

Before attempting to define DevOps, let’s first make it clear - Dev means software development and Ops means operations required to ship and maintain this software.

DevOps is an approach to bring both, the development and the operations cycles together. As student developers, we are usually on the developer cycle - plan a new feature, build it, push it - deployment and similar operations usually come last. However, DevOps advocates for practices wherein each new development in the software is followed by a series of steps such as configuration, deployment, monitoring, quality assurance, and a lot more.

The DevOps cycle

But why do such operations need to be coupled with the development cycle? To increase velocity of delivering new features of a project with CI/CD and automation. Companies like Google and Meta make more than 10000 production pushes in a day across services; this is made possible by adopting DevOps practices, for e.g. according to this talk in 2018, Amazon makes a production push every 11.6 seconds! It also helps to create reliable applications, for example, if you detect an issue or bug in production, a minimal change can be quickly reflected if you have a CI/CD pipeline in place.

How do we implement the DevOps cycle? For the operations cycle to be integrated with software development, there need to be technologies that allow us to package, configure and easily deploy our code. Containerization is an approach that is widely adopted for the same. And what technology pioneered the use of containers? - Docker!

1 - Docker

The pioneer in containerization

Docker provides various services such as the Docker daemon (dockerd), Docker CLI, and Docker Hub Registry that help package applications in containers and host them. As we learned in containers, the several problems of software not being able to run on some machine and portability of software are solved by containers and Docker provides salient tools to make it possible.

Docker logo

Docker architecture

Let’s discuss the architecture of Docker Engine which comprises of Docker client (CLI), Docker Host that contains the Docker daemon which manages the different containers, and the software that needs to be packaged to a container i.e., an image made available on a registry.

Docker architecture

Docker Hub

This is the default registry that Docker uses to fetch images to be run inside containers. But what is an image? A Docker image is a template file that contains the instructions to create a container. Each image has a base image typically a minimal Linux-based operating system such as Alpine and on top of this image, we can add layers of our own images. This can be done using a Dockerfile.

The following is an example Dockerfile:

FROM python:3.7
LABEL maintainer="Pankaj Khushalani"

COPY ./exercises/python-helloworld /app
WORKDIR /app
RUN pip install -r requirements.txt

CMD [ "python", "app.py" ]

Each line contains a keyword following by a flag or a command to be run. In the first line of the Dockerfile, the base image follows the FROM keyword. Here, python:3.7 is the name of the base image, which is hosted on Docker Hub and is downloaded when this Dockerfile is run. python:3.7 contains the Linux-based light-weight OS Alpine which comes with Python version 3.7 installed on it.

Docker daemon

This is the server that hosts and manages the several Docker containers that we would like to run. The communication between different containers is also handled by the daemon. It also plays an important role in creating a Docker container from images pulled from Docker Hub.

Docker CLI

You can interact with the Docker daemon using Docker CLI. This includes creating a Docker container from a Dockerfile or an image directly fetched from Docker Hub, interacting with a Docker container, managing them, etc. You can read the documentation for the list of available commands.

Learn

  • Install Docker and have a go at it! Docker Engine comes with Docker Desktop for Windows and macOS, while for Linux distributions, Docker Engine can directly be downloaded and used. You can find the installation guide here.

  • DevOps with Docker is an MOOC by the University of Helsinki and a great resource to learn the ins and outs of Docker.

  • A video tutorial on Docker from Tech World With Nana