The DevOps Roadmap: Docker

Published 13.03.2021

Author Hrittik Roy

Categories Engineering

Table of Contents

The containerization revolution has just begun, which means you have heard about docker at least once in your professional life. Containerization has made our apps’ deployment cycle faster and efficient. Leading the containerization wave is docker, the most popular container runtime.

Containers, containerization doesn’t click so well? Read this curated post to get accustomed to every prerequisite.

Back to dockers, and in this post, we would dive into this topic and understand its ins and outs with a high-level overview.

What is Docker?

Docker is a tool or platform that makes it easier to create, deploy, package, and ship applications and their components like libraries and other dependencies together. Its main goal is to simplify the application deployment process on Linux. Linux because it’s the most used server OS.

docker
Docker. Source:Freecodecamp

The container runtime enables many containers to operate on the same hardware (aka virtualization), resulting in increased efficiency, isolation of applications, and ease of configuration.

How does Docker work?

Docker packs an application and all of its dependencies in a virtual container that can be run on any Linux server. To function the docker container is composed of the following components:

Daemon: The Docker daemon ( dockerd ) manages Docker resources such as images, containers, networks, and volumes by listening for Docker API requests. To control Docker services, a daemon may interact with other daemons.

High-Level REST API: It allows users to communicate with the daemon or the dockerd.

A CLI: It is a command-line tool (aka docker client) that lets you talk to the Docker daemon.

Docker Engine
Docker Engine. Source: FAUN

How is a docker container built?

Docker containers are built using a docker image which in turn is created using a dockerfile.

What’s dockerfile?

The dockerfile consists of the instructions which are needed to build a docker image. Every time you run a new command, a new layer is built on top of the existing layer in the docker image called intermediate images.

A simple Node.js docker file:

FROM node:stable
COPY . /usr/src/app/
RUN npm install && npm run build
EXPOSE 3000
ENTRYPOINT ["npm", "start"]

What is a docker image?

If you build using the dockerfile, the result is called a docker image. To build use the command docker build. The docker image is layered and hashed, with each layer containing new instructions.

Docker container images hashed
Hashed Container Image layers. Source: FAUN

Since all layers are hashed, Docker can cache them and reduce build times for layers that don’t change between builds. If the COPY phase hasn’t changed, you won’t have to restore and re-copy any of the files, saving you a lot of time in the build process.

Docker builds a new thin writable layer on top of all other layers at the end of the build process.

So, what’s the docker container?

The docker container is the running instance of the docker image.

We can sum things up as:

  • dockerfile is a recipe for creating Docker images
  • A Docker image gets built by running a Docker command (which uses that dockerfile)
  • A Docker container is a running instance of a Docker image

What are docker registries?

It’s not always necessary that you need to build all the images on your own using custom dockerfile. It’s a common practice to pull images (use docker pull) from Docker registries or the store containing many prebuilt images.

So common that if you pick a course, you will interact with pulling docker images from repositories and not building from your own dockerfile.

Docker image being pulled from Registry
Docker image being pulled from Registry. Source: Docker docs

Docker provides an option to have public or private (for inter-organization use) registries to help you with the hassle of building images on your own every time. You can get images from them and also upload your own images to use later on by using docker push.

Commands Crash Course

You might have come across many commands in this post, and this section summarizes all of these commands for you to reference.

$ docker build

This command is used to build a fresh image from your docker file and store it to your local docker image directory. This image can later be published to registry.

$ docker pull

This command lets you pull an existing image from a docker registry and save it to your local docker image directory. Later on, this image can be used to spin up containers.

$ docker run

This command lets you run a container out of an existing container image.

$ docker push

This command helps you to push an image or a repository to a registry.

Final Thoughts

I hope this post helped you understand docker and its key terminologies besides the back-end with the daemon and APIs. Docker is a leap, and if you want to explore more, like why docker is better than VMs.

You can read this post.

Interested in best containerization practices? Here we go!

That’s it for now, then. Thanks for reading, and don’t forget to check the official docker docs for more information.

Happy Containerizing!

More stories from our blog

The DevOps Roadmap: 7 Containerization Best Practices

The DevOps Roadmap: 7 Containerization Best Practices

Containers have the opportunity for developers to build predictable environments isolated from other applications. The application's software dependencies can also be bundled in containers, such as particular versions of programming language runtimes and other...

The DevOps Roadmap: Virtualization

The DevOps Roadmap: Virtualization

The Full-Stack Developer's Roadmap Part 1: FrontendThe Full-Stack Developer's Roadmap Part 2: BackendThe Full-Stack Developer's Roadmap Part 3: DatabasesThe Full-Stack Developer's Roadmap Part 4: APIsThe DevOps Roadmap: Fundamentals with CI/CDThe DevOps Roadmap: 7...

How to Increase Your Luck Surface Area

How to Increase Your Luck Surface Area

In September 2020, I was actively looking to grow as a freelancer. I applied to hundreds of position and sometimes underbid, but results didn’t even make me smile. Opportunities don’t come to you when you start; you need to create them for yourself. I assumed I am not...

Cloud Computing models: SaaS vs IaaS vs PaaS

Cloud Computing models: SaaS vs IaaS vs PaaS

Companies embrace cloud computing worldwide, and the forecasted size of 1025.9 billion USD by 2026 says the same story. Owning and managing infrastructure comes with a considerable cost and improper utilization of human resources. Companies are meant to foster...

What is Cloud Computing?

What is Cloud Computing?

"Cloud Computing" describes a set of terms that you hear everywhere nowadays. It might be in your morning newspaper, or the cool kid you know talks about it with few jargon terms like scalability, elasticity, etc. and now you want to know about these terms. I might...

How To Stop Taking Things Personally

How To Stop Taking Things Personally

Some things hide until we realize that they’re a part of us. I was also a victim of my mind and never discovered this dark side until recently. Whenever I wasn’t taken into consideration or mistreated, I couldn't stop taking things personally. I used to give control...

The Ins and Outs of Content Delivery Networks (CDN)

The Ins and Outs of Content Delivery Networks (CDN)

It is not a hidden fact that everybody’s day-to-day operations would become slow without caching. For example, the amount of time required for each component to load in a web application will add up quickly and might drive our users towards using alternatives. Ask any...

The DevOps Roadmap: 7 Best Practices in CI/CD

The DevOps Roadmap: 7 Best Practices in CI/CD

The Full-Stack Developer's Roadmap Part 1: FrontendThe Full-Stack Developer's Roadmap Part 2: BackendThe Full-Stack Developer's Roadmap Part 3: DatabasesThe Full-Stack Developer's Roadmap Part 4: APIsThe DevOps Roadmap: Fundamentals with CI/CDThe DevOps Roadmap: 7...

The DevOps Roadmap: Fundamentals with CI/CD

The DevOps Roadmap: Fundamentals with CI/CD

The Full-Stack Developer's Roadmap Part 1: FrontendThe Full-Stack Developer's Roadmap Part 2: BackendThe Full-Stack Developer's Roadmap Part 3: DatabasesThe Full-Stack Developer's Roadmap Part 4: APIsThe DevOps Roadmap: Fundamentals with CI/CDThe DevOps Roadmap: 7...

The Full-Stack Developer’s Roadmap Part 4: APIs

The Full-Stack Developer’s Roadmap Part 4: APIs

The Full-Stack Developer's Roadmap Part 1: FrontendThe Full-Stack Developer's Roadmap Part 2: BackendThe Full-Stack Developer's Roadmap Part 3: DatabasesThe Full-Stack Developer's Roadmap Part 4: APIsThe DevOps Roadmap: Fundamentals with CI/CDThe DevOps Roadmap: 7...

Interested in what we do? Looking for help? Wanna talk about software strategy?