DEV Community

Cover image for Absolute beginner's guide to Docker: What is a container?
Erin Schaffer for Educative

Posted on • Originally published at educative.io

Absolute beginner's guide to Docker: What is a container?

Docker is an open-source software platform that helps you simplify the process of creating, managing, running, and distributing your applications. With Docker, you can package your application along with all its dependencies into a container. Containers allow your applications to be deployed easily and uniformly.

Today, we’ll dive deeper into Docker and discuss containers, modules, key terms, and more.

We'll cover:

What is Docker?

Docker is an open-source software that runs on Linux and Windows. With Docker, you can package your application and its dependencies together into containers. Docker allows you to separate your applications from your infrastructure.

The company started as a platform as a service that was built on Linux containers. To help make and manage the containers, they built an in-house tool that they nicknamed “Docker,” which is how the technology was born. The first version was released in 2013.

Today, Docker dominates the market. Many companies use Docker to simplify the process of building, running, and managing applications. It has changed the way companies do their application development. Docker virtualizes the operating system of the computer on which it’s installed, which gives it the functionality of being extremely portable.

Docker is used in:

  • DevOps
  • Software
  • IT services
  • Staffing and recruiting
  • Finance
  • Healthcare
  • Retail
  • Etc.

Before we get into anything else, let’s talk about Docker containers.

What are containers?

For a long time, companies have been using container technologies to address the weak points of virtual machines. We can think of containers as more lightweight versions of VMs. The important difference between containers and VMs is that containers don’t need their own operating system. All containers on a host share that host’s operating system, which frees up a lot of system resources.

What are now modern containers started as Linux containers (LXC). Many contributors, including Google, have helped bring container-related technologies to the Linux kernel. Without these contributions, we wouldn’t have the rich container ecosystem we have today.

Containerization wasn’t very accessible until Docker came along. Docker containers create an abstraction at the application layer. Containers package your application and its container dependencies with everything it needs to run, including:

  • the operating system
  • application code
  • runtime
  • system tools
  • system libraries
  • etc.

Docker modules

Docker offers many different modules and plugins. Let’s take a look at some of the most popular ones.

Docker Compose

docker-compose allows you to define and run multi-container applications. With Compose, you use a YAML file to configure your app’s services and orchestrate containers on a Docker daemon or on Docker Swarm. You can think of it as an automated multi-container workflow. Docker Compose is great for development, testing, CI workflows, and staging environments.

Docker Machine

docker-machine allows you to deploy your containerized applications to the cloud. With Docker Machine, you can create a remote virtual machine and manage your containers. It’s a great tool for creating deployment environments and managing micro-services that run on your application. It can be used with popular cloud services such as AWS and Microsoft Azure.

Docker stack

Docker stack allows you to manage a cluster of Docker containers with Docker Swarm. Docker stack is embedded into the Docker command-line interface (CLI). With stack, you can describe multiple services in a single file. It eliminates the need to maintain bash scripts to define services.

Docker Swarm

Docker Swarm allows you to manage multiple containers across different host machines. In other words, it’s a container orchestration tool. With Swarm, you can turn multiple Docker hosts into a single host.

Docker vs Kubernetes

It’s very common to confuse Docker with Kubernetes, so let’s take some time to look at the differences between the two technologies. These technologies complement one another very well, and they are frequently used together.
We’ve already explored Docker in this article, but let’s highlight some key points.

Docker

Docker is a containerization platform. We can use Docker to build and run containers. Docker Engine is a runtime environment that allows you to build and run containers on a development machine. Operating applications can be complex, especially when you have a lot of containers deployed across various servers. It can be difficult to determine the best way to coordinate and schedule multiple containers, to figure out how they communicate with one another, and to decide how to scale your containers. This is where Kubernetes comes in!

Kubernetes

Kubernetes is an open-source orchestration software for containerization platforms like Docker. It has an API that controls container operations. Kubernetes allows you to organize a cluster of VMs and schedule containers to run on those VMs. With Kubernetes, you can run Docker containers and manage your containerized applications. Your containers are grouped into pods, and you can scale and manage these pods however you want.

Wait, what’s the difference between Kubernetes and Docker Swarm?

As we discussed above, Docker Swarm allows you to manage multiple containers across different host machines.

The difference between Docker Swarm and Kubernetes is that Kubernetes is much more comprehensive than Docker Swarm. It runs across a cluster while Docker runs on one node. Kubernetes pods are divided across nodes to ensure availability.

Docker vocabulary guide

Let’s take a look at some common Docker terms you’ll see when working with the platform.

  • Cgroups: Control groups allow you to allocate resources among processes running on a system.

  • Container images: Docker images are files that you use to execute code in a Docker container.

  • Docker build: docker build is a command that you use to build an image from a Dockerfile.

  • Docker Engine: Docker Engine is the core product of Docker, which includes its daemon and CLI. It has an API for interacting with the Docker daemon.

  • Dockerfile: A Dockerfile is a text-based document that holds the instructions for building Docker images.

  • Docker Hub: Docker Hub is a service that allows you to find and share containers with your organization.

  • Docker Registry: Docker Registry allows you to store and distribute named Docker images. Registries are organized into repositories, and they hold all of the versions of different images.

  • Docker run: The run command allows you to create a container from a specified image and start that container using a given command.

  • Namespace: Namespaces are created when you run a container. They provide a layer of isolation, as each element of a container runs in a different namespace.

  • Pull: docker pull is a command that allows you to download a specific image or set of images.

  • Repository (repo): Docker repositories allow you to share container images with others. These images are stored as tags.

  • Tags: Docker tags are like labels that you can assign to any completed build.

  • Union filesystem (AUFS): A union filesystem layers multiple directories on a single host and presents them as a single directory.

Installing Docker

There many different ways and places to install Docker. We’ll walk through the installation of the Docker Desktop for Windows 10, Mac, and Linux.

Docker Desktop is an application that allows you to build and share containerized applications and micro-services. According to the Docker documentation, it includes:

  • Docker Engine
  • Docker CLI client
  • Docker Compose
  • Docker Content Trust
  • Kubernetes
  • Credential Helper

Windows 10 installation

Before you can download Docker Desktop on Windows 10, you must have the following:

  • 64-bit version of Windows 10 Pro, Enterprise, or Education
  • Hardware virtualization support must be enabled in your system’s BIOS
  • The Hyper-V and Containers features must be enabled in Windows

Start with a Google search for “install Docker Desktop.” This search will take you to the download page where you can download the installer and follow the instructions.

Once it’s installed, you may have to manually start the Desktop from the Windows Start menu.

Mac installation

As with the Windows 10 installation, the easiest way to install Docker Desktop on your Mac is to Google “install Docker Desktop.” From there, you can follow the links on the download page.

Once it’s installed, you may have to manually start the Desktop from the MacOS Launchpad.

Note: With Mac, the Docker Engine doesn’t run natively on the MacOS Darwin kernel. The Docker daemon runs inside a lightweight Linux VM that exposes the daemon and API to your Mac environment. This means that you can open a terminal on your Mac and use Docker commands.

Linux installation

There are many ways to install Docker on Linux. You can Google search for Docker installation guides on Linux. In this section, we’ll take a look at one of the ways you can install Ubuntu Linux 20.04 LTS. We’ll assume you already have Linux installed. We’ll install Docker in two steps:

1. Update the apt package index

$ sudo apt-get update

Get:1 http://eu-west-1.ec2.archive.ubuntu.com/ubuntu.com/ubuntu focal InRelease [265
kb]

...
Enter fullscreen mode Exit fullscreen mode

2. Install Docker from the official repo

$ sudo apt-get install docker.io

Reading package lists... Done

Building dependency tree

...
Enter fullscreen mode Exit fullscreen mode

What to learn next

Congrats on taking your first steps with Docker! Docker is a popular open-source containerization platform that’s used in many different industries to simplify the process of building, securing, and managing applications. With Docker in such high demand, it’s a great tool to add to your skillset.

A great way to get practical experience with Docker is to build a project to add to your professional portfolio. Before you get started, there are still many more things to learn about Docker such as:

  • Container lifecycle
  • Docker commands
  • Creating a new container
  • Running containers

To get started learning these concepts and much more, check out Educative’s curated course The Beginners Guide to Docker. In this hands-on course, we’ll guide you through the basics of Docker to help you gain proficiency in the platform. By the end of the course, you’ll be ready to build your own Docker project to add to your portfolio!

Happy learning!

Continue learning about Docker

Oldest comments (0)